[JBoss Messaging] - JBoss7 integration with Tibco EMS using 'Generic JMS RA'
by Yevgen Kravchenko
Yevgen Kravchenko [https://community.jboss.org/people/ykravchenko] modified the document:
"JBoss7 integration with Tibco EMS using 'Generic JMS RA'"
To view the document, visit: https://community.jboss.org/docs/DOC-47346
--------------------------------------------------------------
*Warning!* This solution might not be perfect, it's not fully tested so please use it on your own risk.
h3. Introduction
It turned out that old approaches to integrate Jboss with Tibco EMS (for example https://community.jboss.org/docs/DOC-14734 this one) will not work for Jboss7. Now we need to use vendor provided Resource adapter (RA), but TibcoEMS is not providing one, what should we do? There is a number of forum threads (for example https://community.jboss.org/message/730006#730006 here) requesting Jboss7 /Tibco EMS integration but none of them is giving a complete set of steps to follow.
In this article I'm going to share some ideas on how to configure Jboss7 to work with Tibco messaging.
h3. Generic JMS resource adapter
TibcoEMS is not providing resource adapter that we could use to integrate with Jboss7, that leaves us no choice but write our own Resource adapter. That is bright idea and will definitely work better then what will follow next, but creating custom RA is time consuming task. Instead of reinventing the wheel we could use http://genericjmsra.java.net/ Generic JMS resource adapter.
However downloading generic resource adapter and deploying it to Jboss7 will not work, you'll most certainly fail with errors stated https://community.jboss.org/message/759055#759055?tstart=0 here. So you'll have to update generic jms ra alittle.
h4. Generic JMS RA project checkout
To checkout source code please follow this http://java.net/projects/genericjmsra/sources link, if you don't want to update source yourself you could skip next parts of article and download updated genericra.rar from attachments.
Steps to configure ANT properties to build project are described http://java.net/projects/genericjmsra/sources/svn/content/trunk/README.bu... here.
h4. Fixing deployment errors
When deploying genericra.rar to Jboss7 you'll get 2 errors:
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.QueueProxy
and
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.TopicProxy
The easiest fix you need to do - force 2 classes implement required interfaces. This is the example of QueueProxy that I came up with
public class QueueProxy extends DestinationAdapter implements javax.jms.Queue, Referenceable, Serializable {
/* The rest of the code is skipped. This is what I've added in order for QueueProxy to be Referenceable*/
private Reference reference;
public void setReference(Reference reference) {
this.reference = reference;
}
public Reference getReference() throws NamingException {
return reference;
}
}
Same should be done with TopicProxy as well. After this changes genericra.rar will deploy with no errors to Jboss7.
h4. Updating Generic JMS RA config
Next we need to change SupportsXA config property in ra.xml (genericra.rar/META-INF). It will cause an issue if you want to use it. In default config it's String while in Java code this property is Boolean. So we need to change from:
<config-property>
<config-property-name>SupportsXA</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
to:
<config-property>
<config-property-name>SupportsXA</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
</config-property>
Please note, that some other properties which cause warnings could be fixed too, but in my case I needed only SupportsXA from the list of "wrong configured by default" properties.
h3. Configure Tibco JMS client libraries in JBoss7
* Create the following folders structure *[Jboss7]\modules\com\tibco\tibjms\main*
* Copy *tibjms.jar* and *tibcrypt.jar* to *[Jboss7]\modules\com\tibco\tibjms\main*
* Create *module.xml* with the following content:
<module xmlns="urn:jboss:module:1.1" name="com.tibco.tibjms">
<resources>
<resource-root path="tibjms.jar"/>
<resource-root path="tibcrypt.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.jms.api"/>
</dependencies>
</module>
* Open *[Jboss7]\modules\org\jboss\as\ee\main\module.xml* and add dependency to com.tibco.tibjms
<dependencies>
<!-- Don't delete what was written here, just add com.tibco.tibjms at the bottom -->
<module name="com.tibco.tibjms"/>
</dependencies>
h3. Configure Tibco EMS
In Tibco EMS create connection factory and queue that you would like to use. The following command in TibcoEMS Administrator tool will help you do that:
tcp://localhost:7222> create factory MyConnectionFactory xaqueue url=tcp://tibcohost:7222
And create queue:
tcp://localhost:7222> create queue MySampleQueue
h3. Configure Resource Adapter in Jboss7
Deploy genericra.rar - it should deploy fine without any exceptions. In the administrator console create new Resrouce Adapter providing archive name *genericra.rar*. Add following properties:
ProviderIntegrationMode=jndi
UserName=[Your Tibco EMS admin username]
Password=[Your Tibco EMS admin password]
JndiProperties=java.naming.factory.url.pkgs=com.tibco.tibjms.naming,java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory,java.naming.provider.url=[Tibco host URL]:7222
SupportsXA=true
LogLevel=finest
Open standalone.xml ([Jboss7]\standalone\configuration\standalone.xml) and add the following lines in <subsystem xmlns="urn:jboss:domain:ejb3:1.2">
<mdb>
<resource-adapter-ref resource-adapter-name="genericra.rar"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
h3. Create Sample MDB
When creating MessageDriven beans you need to use org.jboss.ejb3.annotation.ResourceAdapter to let container know that you want to use external messaging provider. Please find below sample message driven bean that you could use to check that integration is working:
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "MySampleQueue"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "MyConnectionFactory"),
})
@ResourceAdapter("genericra.rar")
public class SampleMdb implements MessageListener {
@Override
public void onMessage(Message message) {
System.out.println("TibcoEMS integration is working!");
}
}
To test that MDB is listening to TibcoEMS queue use this code:
@Test
public void testOnMessage() throws Exception {
Properties properties = new Properties();
properties.put("java.naming.factory.url.pkgs", "com.tibco.tibjms.naming");
properties.put("java.naming.factory.initial", "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
properties.put("java.naming.provider.url", "tibcohost:7222");
InitialContext context = new InitialContext(properties);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("MyConnectionFactory");
Connection connection = connectionFactory.createConnection();
Destination destination = (Destination) context.lookup("MySampleQueue");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
producer.send(message);
}
Hope this article is helpful.
Thanks,
Yevgen Kravchenko
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-47346]
Create a new document in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
12 years, 2 months
[JBoss Messaging] - JBoss7 integration with Tibco EMS using 'Generic JMS RA'
by Yevgen Kravchenko
Yevgen Kravchenko [https://community.jboss.org/people/ykravchenko] modified the document:
"JBoss7 integration with Tibco EMS using 'Generic JMS RA'"
To view the document, visit: https://community.jboss.org/docs/DOC-47346
--------------------------------------------------------------
*Warning!* This solution might not be perfect, it's not fully tested so please use it on your own risk.
h3. Introduction
In turned out that old approaches to integrate Jboss with Tibco EMS (for example https://community.jboss.org/docs/DOC-14734 this one) will not work for Jboss7. Now we need to use vendor provided Resource adapter (RA), but TibcoEMS is not providing one, what should we do? There is a number of forum threads (for example https://community.jboss.org/message/730006#730006 here) requesting Jboss7 /Tibco EMS integration but none of them is giving a complete set of steps to follow.
In this article I'm going to share some ideas on how to configure Jboss7 to work with Tibco messaging.
h3. Generic JMS resource adapter
TibcoEMS is not providing resource adapter that we could use to integrate with Jboss7, that leaves us no choice but write our own Resource adapter. That is bright idea and will definitely work better then what will follow next, but creating custom RA is time consuming task. Instead of reinventing the wheel we could use http://genericjmsra.java.net/ Generic JMS resource adapter.
However downloading generic resource adapter and deploying it to Jboss7 will not work, you'll most certainly fail with errors stated https://community.jboss.org/message/759055#759055?tstart=0 here. So you'll have to update generic jms ra alittle.
h4. Generic JMS RA project checkout
To checkout source code please follow this http://java.net/projects/genericjmsra/sources link, if you don't want to update source yourself you could skip next parts of article and download updated genericra.rar from attachments.
Steps to configure ANT properties to build project are described http://java.net/projects/genericjmsra/sources/svn/content/trunk/README.bu... here.
h4. Fixing deployment errors
When deploying genericra.rar to Jboss7 you'll get 2 errors:
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.QueueProxy
and
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.TopicProxy
The easiest fix you need to do - force 2 classes implement required interfaces. This is the example of QueueProxy that I came up with
public class QueueProxy extends DestinationAdapter implements javax.jms.Queue, Referenceable, Serializable {
/* The rest of the code is skipped. This is what I've added in order for QueueProxy to be Referenceable*/
private Reference reference;
public void setReference(Reference reference) {
this.reference = reference;
}
public Reference getReference() throws NamingException {
return reference;
}
}
Same should be done with TopicProxy as well. After this changes genericra.rar will deploy with no errors to Jboss7.
h4. Updating Generic JMS RA config
Next we need to change SupportsXA config property in ra.xml (genericra.rar/META-INF). It will cause an issue if you want to use it. In default config it's String while in Java code this property is Boolean. So we need to change from:
<config-property>
<config-property-name>SupportsXA</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
to:
<config-property>
<config-property-name>SupportsXA</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
</config-property>
Please note, that some other properties which cause warnings could be fixed too, but in my case I needed only SupportsXA from the list of "wrong configured by default" properties.
h3. Configure Tibco JMS client libraries in JBoss7
* Create the following folders structure *[Jboss7]\modules\com\tibco\tibjms\main*
* Copy *tibjms.jar* and *tibcrypt.jar* to *[Jboss7]\modules\com\tibco\tibjms\main*
* Create *module.xml* with the following content:
<module xmlns="urn:jboss:module:1.1" name="com.tibco.tibjms">
<resources>
<resource-root path="tibjms.jar"/>
<resource-root path="tibcrypt.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.jms.api"/>
</dependencies>
</module>
* Open *[Jboss7]\modules\org\jboss\as\ee\main\module.xml* and add dependency to com.tibco.tibjms
<dependencies>
<!-- Don't delete what was written here, just add com.tibco.tibjms at the bottom -->
<module name="com.tibco.tibjms"/>
</dependencies>
h3. Configure Tibco EMS
In Tibco EMS create connection factory and queue that you would like to use. The following command in TibcoEMS Administrator tool will help you do that:
tcp://localhost:7222> create factory MyConnectionFactory xaqueue url=tcp://tibcohost:7222
And create queue:
tcp://localhost:7222> create queue MySampleQueue
h3. Configure Resource Adapter in Jboss7
Deploy genericra.rar - it should deploy fine without any exceptions. In the administrator console create new Resrouce Adapter providing archive name *genericra.rar*. Add following properties:
ProviderIntegrationMode=jndi
UserName=[Your Tibco EMS admin username]
Password=[Your Tibco EMS admin password]
JndiProperties=java.naming.factory.url.pkgs=com.tibco.tibjms.naming,java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory,java.naming.provider.url=[Tibco host URL]:7222
SupportsXA=true
LogLevel=finest
Open standalone.xml ([Jboss7]\standalone\configuration\standalone.xml) and add the following lines in <subsystem xmlns="urn:jboss:domain:ejb3:1.2">
<mdb>
<resource-adapter-ref resource-adapter-name="genericra.rar"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
h3. Create Sample MDB
When creating MessageDriven beans you need to use org.jboss.ejb3.annotation.ResourceAdapter to let container know that you want to use external messaging provider. Please find below sample message driven bean that you could use to check that integration is working:
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "MySampleQueue"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "MyConnectionFactory"),
})
@ResourceAdapter("genericra.rar")
public class SampleMdb implements MessageListener {
@Override
public void onMessage(Message message) {
System.out.println("TibcoEMS integration is working!");
}
}
To test that MDB is listening to TibcoEMS queue use this code:
@Test
public void testOnMessage() throws Exception {
Properties properties = new Properties();
properties.put("java.naming.factory.url.pkgs", "com.tibco.tibjms.naming");
properties.put("java.naming.factory.initial", "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
properties.put("java.naming.provider.url", "tibcohost:7222");
InitialContext context = new InitialContext(properties);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("MyConnectionFactory");
Connection connection = connectionFactory.createConnection();
Destination destination = (Destination) context.lookup("MySampleQueue");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
producer.send(message);
}
Hope this article is helpful.
Thanks,
Yevgen Kravchenko
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-47346]
Create a new document in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
12 years, 2 months
[jBPM] - Re: Session and thread safety
by Gábor Farkas
Gábor Farkas [https://community.jboss.org/people/hhcofcmds] created the discussion
"Re: Session and thread safety"
To view the discussion, visit: https://community.jboss.org/message/759641#759641
--------------------------------------------------------------
The same problem here, still exists in JBpm5, 5.3.0.Final
The problem is that SingleSessionCommandService calls beginCommandScopedEntityManager on the PersistenceContextManager, but the endCommandScopedEntityManager in called when the transaction commits. When used in an EE environment, the JTA transaction commits well after the SingleSessionCommandService exits the synchronized block.
If another requests comes, and the execution enter the critical section, the CMD_SCOPED_ENTITY_MANAGER is still stored in the environment, so the new request will just use the EntityManager from the previous request, which clearly causes serious problems.
I think that this should be reportes as a bug in Jbpm5, because this prevents the correct usage of JBpm in an enterprise container. What do you think?
In my workaround, I created a CDI interceptor that synchronizes methods that use KnowledgeSession on a higher level.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/759641#759641]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 2 months
[jBPM] - Can we migrate case-flows from Savvion to jBPM?
by Vidhya Prabhu
Vidhya Prabhu [https://community.jboss.org/people/vidhyakp28] created the discussion
"Can we migrate case-flows from Savvion to jBPM?"
To view the discussion, visit: https://community.jboss.org/message/759567#759567
--------------------------------------------------------------
Hi,
I am a newbie, and am very interested in process development in jBPM. I have a very interesting usecase at hand and need to give solution in its implementation.
We have currently implemented our BPM flow using Savvion 6.5 product. We are searching for an open source solution to migrate existing business flow. I found jBPM suitable for the requirement.
There are certain queries that I need to understand:
1. Is it possible to migrate existing case flows from Savvion to jBPM ?
2. If yes, how could we migrate from Savvion to jBPM?
3. If in case there is no solution, what details are required to have a customized utility for the same?
Our application is purely JEE based deployed on Weblogic Server and we use jax-WS to integrate with Savvion. So, I assume we can do the same using jBPM web-services.
Let me introduce to what we have implemented in the Savvion product:
We create business flow mainly using subprocesses (call-activity with child sub-processes in different templates), swim-lanes, split/XOR gateways, data variables, LDAP connectors etc. available in Savvion.
We have 4-5 case types and each case-type has its own workflow. Every workflow has four phases and each phase has phase-activities which in-turn has worksteps (templates).
1. Phases could be intial, in-progress, contract and production.
2. Phase-activities are department specific. For eg. Sales, Operation etc.
3. Worksteps are assigned to a group(team) or specific user.
Certain worksteps have some business-rule validation before execution which requires to be fulfilled.
The approach used is using of tokens. A workstep can have many validation tokens separated by comma. e.g VALIDATE_EMAIL,VALIDATE_USERNAME.
Once we deploy this business flow, using Savvion BPM Studio, it internally copies the BPM related files to server and +*creates a table for each template*+.
Now the process is as follows:
1. Application has a provision to start the process flow - Savvion creates a process instance for the template and add one entry in respective database table. For eg, we have a template name 'App_CustomerContact', table name same as template name. This process-instance is related to only one case.
2. The application makes user available with assigned worksteps in the form of checklist. The user then completes these worksteps (We call it as measure-points). Once the user has completed his assigned worksteps, the next workstep will be available to team/other user as per business flow.
So we require to migrate our existing process-instances into jBPM and also create new processes using jBPM templates.
We do have knowledge how Savvion creates data into its database.
I am attaching a sample workflow template developed in Savvion BPM.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/759567#759567]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 2 months