Pages

Thursday, May 15, 2014

ActiveMQ & IIB with JMS

In this topic I will give you some hints on how to connect your IBM Integration Bus to a JMS provider ActiveMQ.
The following link is very useful:
http://www.ibm.com/developerworks/websphere/library/techarticles/1211_eswarachary/1211_eswarachary.html
There are however few information concerning the configuration.
I provided here after some extra informatio.

Configuration

Runtime configuration

In the MQ Explorer, select the "JMSProviders/ActiveMQ" configurable service  of the Integration node you want to use.




 The default_Path refers to the shared class directory of the IBM Integration Node.

 The jars of ActiveMQ have to be placed into a directory.
I usually place them in a dedicated directory under the homePath of the IIB Node which on windows is "C:\ProgramData\IBM\MQSI".
You can know the path using following command and look for "Local Work Path":
mqsiservice INodeName



Jar file

In order to be able to access activeMQ, the integration node needs the JMS provider jar file and place them in a location accessible to the node. I found convenient to copy the activemq-all.jar file only.

JNDI Bindings
In order to retrieve the connection factory, the Integration node needs to have a JNDI.
A default JNDI is provided with ActiveMQ: org.apache.activemq.jndi.ActiveMQInitialContextFactory

The jndi objects configuration can be found at the following link:
http://activemq.apache.org/jndi-support.html

You need to make this configuration file, the jndi.properties file, accessible to the IntegrationNode.
As explain at the link:
"
Once you have the jndi.properties edited and ready, it needs to be accessible to your application. The easiest way is to add jndi.properties to a jar file. When "new InitialContext()" is called, it will scan the resources and find the file.
 "
So place the file in a jar file - I just created a zip file, placed the property file in it and renamed the extension to "jar" - and place the jar file in the directory where you put the activemq jars.

In my configuration I have:




And in this directory I have the activemq.jar as well as another jar that contains my file "jndi.properties".

The content of my jndi.properties is:

java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=vm://localhost
connectionFactoryNames=connectionFactory, queueConnectionFactory, topicConnectionFactory
queue.jmsINQ=IN.Q
queue.jmsOUTQ=OUT.Q

There is a default connection factory "connectionfactory" and two queues.
The jndi name for the queue IN.Q defined on ActiveMQ is "queue.jmsINQ". The queue is accessed from the node using the alias name "jmsINQ" (without queue).

IIB Node configuration

Node configuration

The JMS Provider name on the JMSInput node is using a configurable service.
If the corresponding runtime configurable service property is not changed (let the defaulr), the property on the node will be used.
If you change the default property value on the conf. service then this property will be used.


Here is the configuration of my input node:

 

The connection factory "connectionfactory" is the one by default and defined in the jndi.properties.
And in the "basic" tab of the node, I put the alias name defined in the jndi properties file: jmsINQ for the input.



That's it !!

Testing

If you go on active MQ -> admin -> connections
you will see your connection.
Message can be send from ActiveMQ using the "send" tab.


Pretty Print in blogger

Pretty Print in blogger

 I was looking to provide a better way to render code in my blog.
Have found a good solution with the pretifier of google:
https://code.google.com/p/google-code-prettify/wiki/GettingStarted
http://google-code-prettify.googlecode.com/svn/trunk/README.html

Once it has been configured in blogger (see below in the post), you can highlight your code by adding the HTML code
<pre class="prettyprint">
your code
</pre>
HTML code can be added in blogger in this way:
In blogger, click on the button "HTML" at the left top place.
Then  add the tag code <pre... /pre> as described above.


Of course the javascript has to be make accessible from blogger.
I found two way to include this pretifier in my blog.

Using this approach the following code

public void test(){ String test = "hello"; }
would looks like:
public void test(){
   String test = "hello";
}

You can also add line number as explained in the getting started of google using : "prettyprint linenums".
The following code:
lines
of
code

would looks like:
  1. Many
  2. lines
  3. of
  4. code

Using gadget

This is explained at the following link
http://www.virtualzone.de/2012/09/how-to-use-prettyprint-to-format-source.html


The gadget is run when the topic is visualized. Which provide access to the google code prettyprint.


The script is executed when the topic is published.

Using template

 This is my prefer way.
Go to the administration place of blogger, select "template" then edit html.
Add the following line in your html template (I added it under header):



Sharing code/artifacts

I have for long time looking for a place where I could place implementation that I have made and share with others.

I have found some good places.

---------------------------------------
https://hub.jazz.net/

This place is very good and it's free. You can create projects private or not and add your code.
There is a  plugin for eclipse as well: on eclipse the software update url:
https://jazz.net/downloads/rational-team-concert/4.0.6/4.0.6/p2

You can also define tasks, and so forth...

---------------------------------------
https://github.com/

This is also a very good place.
A lot of IBM Integration Bus artifacts are stored and will be stored at this place.
You can create private/public projects.
There is a plugin available on eclipse as well: 
http://download.eclipse.org/egit/updates
You can get more information at
http://eclipse.org/egit/download/

---------------------------------------
https://gist.github.com/

If you have very small code to share with others, this is the place to go !
---------------------------------------
 I will try to get some time to provide more information on one these places.