Have you used the WSO2 MB with AMQP? If not this will help you get
started on AMPQ with WSO2 MB. I am using the newly released
WSO2MB 3.0.0-Alpha4 and RabbitMQ AMQP Java client in this
example.
Setting up the project
For this example, I created a Maven project. Following code correspond
to the pom.xml used in the project
I have added RabbitMQ AMQP client as a dependency in the pom.xml
file.
Publisher
Publisher class connect to the WSO2 MB and publish a simple
text message to the message queue “hello”.
Subscriber - Synchronous
Subscriber code specified below will connect to the WSO2 MB and
retrieve the message published in “hello” message queue and print it
in the console.
Subscriber - Asynchronous
Following Subscription implementation receives messages asynchronously.
Running the example
I assume you have installed the WSO2 MB in your machine and it is run
using the default configuration. You can first run the publisher
code. This will publish a message in to the “hello” queue. Then you
can use subscriber code to retrieve and print the message in the
message queue.
This post include a summary on IBM WebSphere MQ Queue Managers, Queues and Channels. Knowing these concepts will help you to do simple tasks like creating a queue, sending and receiving messages from a queue.
Queue Managers
Queue manager is the top level object that holds in the network (Such as queues and channels). The main tasks done through a queue manager are,
Start channels
Process MQI calls
Create, delete, alter queues and channel definitions
WSO2 GREG uses RXT files to describe the data model of an
artifact. There are mainly two steps in creating an artifact using RXT
files.
Creating the RXT file. You can find details about the syntax used in RXT files in here.
Deploying created RXT file in GREG. This is described in detail in here.
Relationship Model
Following is an explanation about the relationship model used in the
GREG’s RXT files. In RXT files, we use the “relationships element”
(more details here)
to define relationships between two artificats. You can find several
RXT examples inside
1
$GREG_HOME/samples/asset- models
directory. Following is an extract from the sample file
Here in line 2, we have added a “usedBy” association in the TestCase
artifact to the TestSuite artifact using the association element. Note
that we have used source attribute to indicate that the relationship
is from “TestCase” to “TestSuite”. In the line 3 we have added a
dependency in the TestSuite on “TestCase”. Note that we have used the
“target” attribute to indicate that the relationship is from
“TestSuite” to “TestCase”. The relationships element only indicate the
type of relationship. To make it relate to one or many, we can use
different type of fields. You can find a description about available
field types from here.
If we look at the same sample file we took earlier we can see that a
“TestSuite” artifact have an association with many “TestCase”
artifacts. The relevant RXT code is mentioned below.
In line 6 we have defined the field type as “option-text” with
attribute “maxoccurs” set to “unbounded”. Therefore we can add many
TestCases for a Testsuite. If we have used a field of type text field
then a TestSuite can have only one TestCase.
Similarly you can use different combination of the “relationships”
elements and field elements to create different relationship patterns.
Examples
Some Examples are listed below, I am taking “Project group” and
“Person” as artifcats for following examples. I have only shown the
relevant parts of the RXT file. You have to add all other required
elements to make it a valid RXT file.
Have you ever faced a situation where you wanted to execute a function
you want instead of sending the form data when the form submit button is
clicked. This post describes one way you can do just that. This
behavior is very useful in tasks like form data validation. We don’t
want to send form data to server if the data validation fails.
Code snippets
Assume your form has the following structure,
You can override the default form submission behavior by using a
JavaScript function like below for the form’s onsubmit event. Here the
usage of “e.preventDefault()” function is important to avoid form data
submission.
Managing dependencies is one of the important task in developing a
complex Java project. This normally includes searching for depending
libraries and adding them to the Eclipse project. Sometime this is not
a very pleasant task. But the good news is, Maven make it easy to
handle dependencies in Java projects.
Imagine that you want to use a particular Java class in you project
and you want to find and include the corresponding Java library in
your project. You can use http://search.maven.org to search for a
Maven dependency. They have an
advanced search which
is very helpful if you only know the name of the required class.
Adding the dependency to Maven
From the results you get from the search identify the required
library. By clicking on a version number in the search results you can
get the dependency information for a artifact. Following is an example
of Maven dependency snippet.
Updating the eclipse project
Add this dependency information to pom.xml (I assume you already have
and pom.xml in your project directory. If not add a pom.xml or read
this post
to know about creating an Eclipse project using Maven) and run following command to
update the eclipse project.
Alternatively you can also use an Eclipse plugin to handle Maven
dependencies. An example for such a plugin is the
m2eclipse plugin.