web stats
Passing java object to source from JMS queue in Mirth? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2013, 07:15 AM
ashu84 ashu84 is offline
Mirth Newb
 
Join Date: Jun 2013
Posts: 7
ashu84 is on a distinguished road
Question Passing java object to source from JMS queue in Mirth?

I am passing java object from JMS sender client to mirth.Java Class look like this:

Code:
public class OrderDetails implements Serializable{

    private static final long serialVersionUID = -4617153110762983450L;
    private Long mrn;
    private Long orderNo;
    private Long patientId;
    private Long orderId;
    private Long encounterId;

}
JMS client code looks like this:

Code:
public void sendMessage(final OrderDetails orderDetails) throws JMSException {
        LOG.debug("Starting sendMessage of AMQMsgSenderService");
        jmsTemplate.send(new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                LOG.info("SENDING: " + orderDetails);
                ObjectMessage message = session.createObjectMessage( orderDetails );
                return message;
            }
        });
        LOG.debug("Ending sendMessage of AMQMsgSenderService");
    }
Connector Type in Mirth is JMS Reader. I want to receive java object in source and transform into XML or JavaScript Object. Is it possible in Mirth?I am using Mirth Version 2.2.1.5861.

Last edited by ashu84; 07-24-2013 at 12:40 AM.
Reply With Quote
  #2  
Old 07-24-2013, 03:17 AM
ashu84 ashu84 is offline
Mirth Newb
 
Join Date: Jun 2013
Posts: 7
ashu84 is on a distinguished road
Smile

Can anyone give suggestion on this post please??
Reply With Quote
  #3  
Old 07-24-2013, 09:15 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,054
narupley is on a distinguished road
Default

What currently gets received by the channel? Or is there an error?
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 07-25-2013, 02:52 AM
ashu84 ashu84 is offline
Mirth Newb
 
Join Date: Jun 2013
Posts: 7
ashu84 is on a distinguished road
Question

I am getting following error:

Code:
[2013-07-25 02:41:24,405]  ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95): Caught exception in Exception Strategy for: e6c39215-2bca-41f5-8951-4b7a1092a850: org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@f11487, endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#-1649715782', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@1b2a52f, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@f11487, endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#-1649715782', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@1b2a52f, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:64)
	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79)
	at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487)
	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266)
	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225)
	at com.mirth.connect.connectors.jms.JmsMessageReceiver.onMessage(JmsMessageReceiver.java:101)
	at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
	at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
	at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.transformer.TransformerException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails (javax.jms.JMSException) (org.mule.umo.transformer.TransformerException)
	at com.mirth.connect.connectors.jms.transformers.JMSMessageToObject.doTransform(JMSMessageToObject.java:66)
	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
	at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
	... 13 moreCaused by: org.mule.umo.transformer.TransformerException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails (javax.jms.JMSException)
	at com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.transformFromMessage(AbstractJmsTransformer.java:216)
	at com.mirth.connect.connectors.jms.transformers.JMSMessageToObject.doTransform(JMSMessageToObject.java:60)
	... 16 moreCaused by: javax.jms.JMSException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails
	at com.mirth.connect.connectors.jms.JmsMessageUtils.getObjectForMessage(JmsMessageUtils.java:158)
	at com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.transformFromMessage(AbstractJmsTransformer.java:213)
	... 17 more
I have attached the exported XML file for the channel.
Attached Files
File Type: xml JavaObjectIncomingChannel.xml (5.0 KB, 8 views)
Reply With Quote
  #5  
Old 07-26-2013, 07:59 AM
ashu84 ashu84 is offline
Mirth Newb
 
Join Date: Jun 2013
Posts: 7
ashu84 is on a distinguished road
Post

Hi Narupley,

Now i have resolved the previous error.I have created the jar file for class whose object i was getting passed and placed in custom-lib folder of mirth connect.
Now when i am logging that object in source transformer by doing this :

Code:
logger.info("orderDetails " +messageObject.getRawData());


It is printing this :

orderDetails com.nous.domain.OrderDetails@240aaf81

After this i am trying to access one property of that object by calling the getter method:

Code:
var orders  = messageObject.getRawData();
logger.info("orderDetails mrn" +orders.getMrn());


Now i am getting following error :

Code:
[2013-07-26 07:37:29,760]  ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95): Caught exception in Exception Strategy for: e6c39215-2bca-41f5-8951-4b7a1092a850: org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@57f283, endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#663859136', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@364d43, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@57f283, endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#663859136', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@364d43, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:64)
	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79)
	at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487)
	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266)
	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225)
	at com.mirth.connect.connectors.jms.JmsMessageReceiver.onMessage(JmsMessageReceiver.java:101)
	at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
	at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
	at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.transformer.TransformerException: CHANNEL:
	JavaObjectIncomingChannelCONNECTOR:
	sourceConnectorSCRIPT SOURCE:
	SOURCE CODE:
	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
	12DETAILS:
	TypeError: Cannot find function getMrn in object com.nous.domain.OrderDetails@240aaf81. (com.mirth.connect.server.MirthJavascriptTransformerException) (org.mule.umo.transformer.TransformerException)
	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:316)
	at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48)
	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
	at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
	... 13 moreCaused by: org.mule.umo.transformer.TransformerException: CHANNEL:
	JavaObjectIncomingChannelCONNECTOR:
	sourceConnectorSCRIPT SOURCE:
	SOURCE CODE:
	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
	12DETAILS:
	TypeError: Cannot find function getMrn in object com.nous.domain.OrderDetails@240aaf81. (com.mirth.connect.server.MirthJavascriptTransformerException)
	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:410)
	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:296)
	... 20 moreCaused by: com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL:
	JavaObjectIncomingChannelCONNECTOR:
	sourceConnectorSCRIPT SOURCE:
	SOURCE CODE:
	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
	12DETAILS:
	TypeError: Cannot find function getMrn in object com.nous.domain.OrderDetails@240aaf81.
	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:398)
	... 21 more
Please help me on this.I am using Mirth Version 2.2.1.5861. I have attached the exported XML file for the channel for the reference.

Waiting for the reply
Reply With Quote
Reply

Tags
jms, mirth 2.2.1, transfomer, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation