BridgeService between From Tibco EMS queue to Jboss Queue.
maniv Oct 19, 2011 3:44 AM-----------------------------------------------------------------------------------------
Test Case:-
Create BridgeService between From Tibco EMS queue to Jboss Queue.
Environment :-
Server : - jboss-soa-p-standalone.5.0.0
Jdk :- jdk-1.6
copy below jar into <server-path>\jboss-esb\lib\endorsed
jboss-javaee.jar
jboss-common-core.jar
Below config in tibco-jms-ds.xml file
-----------------------------------------
<mbean code="org.jboss.jms.server.bridge.BridgeService"
name="jboss.messaging:service=Bridge,name=TibcoBridge"
xmbean-dd="xmdesc/Bridge-xmbean.xml">
<!-- The JMS provider loader that is used to lookup the source destination -->
<depends optional-attribute-name="SourceProviderLoader">
jboss.messaging:service=JMSProviderLoader,name=TibjmsProvider</depends>
<!-- The JMS provider loader that is used to lookup the target destination -->
<depends optional-attribute-name="TargetProviderLoader">
jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>
<!-- The JNDI lookup for the source destination queue name 'TIBCO.JBOSS.TEST'-->
<attribute name="SourceDestinationLookup">TIBCO.JBOSS.TEST</attribute>
<!-- The JNDI lookup for the target destination -->
<attribute name="TargetDestinationLookup">/queue/dbsync_app1_Q</attribute>
<!-- The username to use for the source connection -->
<attribute name="SourceUsername"></attribute>
<!-- The password to use for the source connection-->
<attribute name="SourcePassword"></attribute>
<!-- The username to use for the target connection-->
<attribute name="TargetUsername">guest</attribute>
<!-- The password to use for the target connection-->
<attribute name="TargetPassword">guest</attribute>
<!-- Optional: The Quality Of Service mode to use, one of:
QOS_AT_MOST_ONCE = 0;
QOS_DUPLICATES_OK = 1;
QOS_ONCE_AND_ONLY_ONCE = 2; -->
<attribute name="QualityOfServiceMode">0</attribute>
<!-- JMS selector to use for consuming messages from the source-->
<attribute name="Selector"></attribute>
<!-- The maximum number of messages to consume from the source
before sending to the target -->
<attribute name="MaxBatchSize">1</attribute>
<!-- The maximum time to wait (in ms) before sending a batch to the target
even if MaxBatchSize is not exceeded.
-1 means wait forever -->
<attribute name="MaxBatchTime">10</attribute>
<!-- If consuming from a durable subscription this is the subscription name
<attribute name="SubName">mysub</attribute>
-->
<!-- If consuming from a durable subscription this is the client ID to use
<attribute name="ClientID">myClientID3</attribute>
-->
<!-- The number of ms to wait between connection retrues in the event connections
to source or target fail -->
<attribute name="FailureRetryInterval">5000</attribute>
<!-- The maximum number of connection retries to make in case of failure,
before giving up -1 means try forever-->
<attribute name="MaxRetries">-1</attribute>
<!-- If true then the message id of the message before bridging will be added
as a header to the message so it is available to the receiver. Can then be
sent as correlation id to correlate in a distributed request-response -->
<attribute name="AddMessageIDInHeader">true</attribute>
</mbean>
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.messaging:service=JMSProviderLoader,name=TibjmsProvider">
<attribute name="ProviderName">TibcoJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="FactoryRef">ConnectionFactory</attribute>
<attribute name="QueueFactoryRef">QueueConnectionFactory</attribute>
<attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
<attribute name="Properties">
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
java.naming.provider.url=tcp://<tipco server ip>:<tipco-queue-port>
</attribute>
</mbean>
-----------------------------------------
send message client program
---------------
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class SendTibcoMessage {
QueueConnection conn;
QueueSession session;
Queue que;
.................
public void setupConnection() throws JMSException, NamingException
{
Properties properties1 = new Properties();
properties1.put(Context.INITIAL_CONTEXT_FACTORY,
"com.tibco.tibjms.naming.TibjmsInitialContextFactory");
properties1.put(Context.PROVIDER_URL, "tcp://<tipco server ip>:<tipco-queue-port>");
InitialContext iniCtx = new InitialContext(properties1);
Object tmp = iniCtx.lookup("QueueConnectionFactory");
QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
conn = qcf.createQueueConnection();
que = (Queue) iniCtx.lookup("TIBCO.JBOSS.TEST");
.........................
public void sendAMessage(String msg) throws JMSException {
QueueSender send = session.createSender(que);
TextMessage tm = session.createTextMessage(msg);
tm.setJMSMessageID("ID:1");
tm.setJMSCorrelationID("ID:1");
send.send(tm);
session.commit();
System.out.println("message sent");
send.close();
}
..................
}
------------------------------------------------------------------------------------------
Exception
----------------------------
11:30:27,925 WARN [Bridge] jboss.messaging:name=TibcoBridge,service=Bridge Failed to send + acknowledge batch, closing JMS objects
- java.lang.UnsupportedOperationException: CorrelationID as byte array is not supported
at com.tibco.tibjms.TibjmsMessage.getJMSCorrelationIDAsBytes(TibjmsMessage.java:360)
at org.jboss.jms.message.JBossMessage.<init>(JBossMessage.java:346)
at org.jboss.jms.message.JBossTextMessage.<init>(JBossTextMessage.java:96)
at org.jboss.jms.client.container.ProducerAspect.handleSend(ProducerAspect.java:220)
at org.jboss.aop.advice.org.jboss.jms.client.container.ProducerAspect_z_handleSend_7115296.invoke(ProducerAspect_z_handleSend_7115296.java)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.jms.client.delegate.ClientProducerDelegate.send(ClientProducerDelegate.java)
at org.jboss.jms.client.JBossMessageProducer.send(JBossMessageProducer.java:165)
at org.jboss.jms.server.bridge.Bridge.sendMessages(Bridge.java:1430)
at org.jboss.jms.server.bridge.Bridge.sendBatchNonTransacted(Bridge.java:1281)
at org.jboss.jms.server.bridge.Bridge.sendBatch(Bridge.java:1395)
at org.jboss.jms.server.bridge.Bridge.access$2000(Bridge.java:68)
at org.jboss.jms.server.bridge.Bridge$SourceListener.onMessage(Bridge.java:1715)
at com.tibco.tibjms.TibjmsxSessionImp._submit(TibjmsxSessionImp.java:3917)
at com.tibco.tibjms.TibjmsxSessionImp._dispatchAsyncMessage(TibjmsxSessionImp.java:2207)
at com.tibco.tibjms.TibjmsxSessionImp$Dispatcher.run(TibjmsxSessionImp.java:3443)
11:37:11,548 WARN [Bridge] jboss.messaging:name=Test3Bridge,service=Bridge Will retry after a pause of 5000 ms
11:37:16,744 INFO [Bridge] jboss.messaging:name=Test3Bridge,service=Bridge Succeeded in reconnecting to servers
-------------------------------
Result :-
Message is successfully sent to Tibco EMS queue.
And then Message is being consumed from Tibco EMS queue.
And then java.lang.UnsupportedOperationException is getting thrown which cause BridgeService get disconnect
-----------------------------
Query :-
- Why java.lang.UnsupportedOperationException is getting thrown eventhough we are using TextMessage not even Object or arrayMessage.
- And why CorrelationID as byte is expected when we are explicit setting correlation id.
--------------------------------------------------------------------------------------------