In the previous post we learn to Creating and Configuring a JMS queue, in this post we will learn to create a message and publishes it in our queue created earlier.
See the links below to check the other parts:
- Working with JMS messages on OSB – Part 1: Creating and Configuring Queues
- Working with JMS messages on OSB – Part 2: Publishing a Message Queue
- Working with JMS Messages on OSB – Part 3: Receiving Message
I’m using Version: 3.6.2 as follows:
Let’s create our XSD to have the input parameters for our message, so that download the XSD DadosDepartamento.xsd
Keep the following in mind: Make an XSD as generic as possible so that we can avoid the high coupling.
This XSD also use it to receive such data in line for we record in our database.
And the place within the XSD folder of your OSB as follows:
Now download our WSDL that will be responsible for creating our Proxy: BlogJmsPublishQueue.wsdl
And the place within the WSDL of your OSB folder as follows:
Note: Above beware if your WSDL and XSD are in the same folder hierarchy and if your project is with the same name as my (OSBProject) so there is no problem in <xs:include as the up arrow, if different check to hit the road.
We will now create our Business Service:
Click on the folder Business
Now click the menu and select File >> New >> Business Service and File Name: Place BlogJmsPublishQueueBusiness.biz and click Finish
In the screen below select the Messaging Service option in the General tab as follows:
Now click on the Messaging tab, and click XML, and then click Browse, then choose the option dadosDepartamentoRequest (element) as shown below and click OK.
So should look like this:
Now click the Transport tab, and then choose Protocol jms and Endpoint URI fill in:
jms://localhost:9000/ConnectionFactoryBlog/BlogQueue
Entenda:
- localhost:9000 = Address of my Domain OSB
- ConnectionFactoryBlog = Name of my ConnectionFactory
- BlogQueue = Name I gave to my Queue
Then click Add and be as follows:
Now click on the JMS Transport tab and select Text Message Type (in this case the message is sent in plain text)
There, we have created our Business, we now create our Proxy which will make this call Business.
Click on the Proxy folder
Now click the menu and select File >> New >> Proxy Service (careful, it’s not Proxy Server because there the two options) and File Name: Place BlogJmsPublishQueueProxy and click Finish
In the General tab click WSDL Web Service and later in Browse, then click BlogJmsPublishQueuePublisherServiceSoapBinding (binding) and click OK
Then we will have the following screen:
Click the Transport tab, and then put EndPoint URI /BlogJmsPublishQueueProxy
Now click the Message Flow tab and drag a Pipeline Pair so that it is as follows:
Within the PipelinePairNode1 and below the Request Pipeline drag a Stage and into the Stage drag a Publish as follows:
Click Publish and below in the Publish Properties tab, click Browse and select the Business we created BlogJmsPublishQueueBusiness.biz and then click OK to we select this Business
Into the now a Replace drag Publish
Click on the Replace box and below Properties do the following:
Click on:
- Replace node contents so that we can do the replace the content of our body
- In XPath click <XPath> and the box that open place just one point. as below:
- In In Variable: put the word body
See below for now looks like this:
Now click <Expression> and the box that opens on your right in the Variable Structures tab put content below which will be the payload through our queue.
<br:dadosDepartamentoRequest xmlns:br=”br.com.uansblog.BlogJmsPublishQueuePublisher”>
<br:numeroDepartamento>{data($body/br:dadosDepartamentoRequest/br:numeroDepartamento)}</br:numeroDepartamento>
<br:nomeDepartamento>{data($body/br:dadosDepartamentoRequest/br:nomeDepartamento)}</br:nomeDepartamento>
<br:localDepartamento>{data($body/br:dadosDepartamentoRequest/br:localDepartamento)}</br:localDepartamento>
</br:dadosDepartamentoRequest>
Note: To get the payload you can call in your SBConsole Business (BlogJmsPublishQueueBusiness.biz) set up and get the contents of the Request and within the payload you will put the data to be received from your Body (for example: $body/br:dadosDepartamentoRequest/br:numeroDepartamento)
It looks like this:
Now in its Response Pipeline drag another Stage and into the Stage drag a Replace so that it is as below:
Click on this new Replace the Properties tab and edit it in Expression be as follows for that drag the RESPONSE operation and put a /* at the end and then click OK
Click again on this Replace box and below Properties do the following:
Click on:
- Replace node contents so that we can do the replace the content of our body
- In XPath click <XPath> and the box that open place just one point. as below:
- In In Variable: coloque a palavra body
Ready, we have made our process for sending the message, now we send the message via Web console.
In your browser go to http://localhost:9000/sbconsole
Note: The 9000 port is the number I chose to create my Domain OSB
Login:
Click Resource Browser and right should appear to our Proxy BlogJmsPublishQueueProxy
The right side in the Actions tab, click the icon that looks like a “green roadster“: and proceed as follows:
<br:dadosDepartamentoRequest xmlns:br=”br.com.uansblog.BlogJmsPublishQueuePublisher”>
<br:numeroDepartamento>50</br:numeroDepartamento>
<br:nomeDepartamento>SISTEMAS</br:nomeDepartamento>
<br:localDepartamento>BRASIL</br:localDepartamento>
</br:dadosDepartamentoRequest>
Click Run and see below how should appear:
There, our Homage was sent …
We will now follow where stop our message:
In your browser go to http://localhost:9000/console
Note: The 9000 port is the number I chose to create my Domain OSB
Login:
In the screenshot below click JMS Modules as follows:
Now click BlogModule
Now click BlogQueue
Now click Monitoring
In the screenshot below we need a view called Messages Current and in this case is not yet showing up if their is can skip this step.
Then click Customize this table as screen above and below as fit for the right column the following items that will be interesting for us analyze now and then click Apply
Now we have:
See you in Messages Current will be the message we send and Messages Total the amount of messages that we send
To view the contents of the message click next to BlogModule! BlogQueue and Show Messages
Now click next to the ID:, that will be a link to display the message:
Okay, here in this post we saw how to create and send a message to our queue, the next post we will see how are we going to eat this message and write it to our database.
Hugs and until the Next
/:-D
Ashish Gupta said:
Hi Uans,
Thank you so much for the fantastic blog.
I am trying to do similar thing, but its failing.
I am building a basic proxy service which has to read messages from JMS Queue.
I created a connection factory and JMS queue, and I am trying to access that queue from my OSB proxy, but its not getting connected.
I am using the url:
jms: // ptseelm-lx4571.ikeadt. with:. 9004 / JmsToJms / lo JmsQueue1
where
ptseelm-lx4571.ikeadt.com is host
9004 is port
JmsToJms is connection factory JNDI
eis.JmsQueue1 is Queue JNDI
But,this setup is not succesful for me.
Can you please help me?
Thanks & Regards,
Ashish
Uans said:
ello Ashish
Unable to see really is hard to analyze, but looking at the URI of your JMS I saw that has some points and the correct would be a slash “/”
An example below:
jms://localhost:12001/NameConnectionFactory/Queue
and even then it does not work try to create a distribuitedQueue in place of the Queue because already had some similar errors on creating a Queue instead of distribuitedQueue
Then tell me please if given right
Regards,
Uans