web stats
Adding String properties to a message in a JMS destination - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2011, 07:56 AM
Ittai Ittai is offline
What's HL7?
 
Join Date: Aug 2011
Posts: 5
Ittai is on a distinguished road
Default Adding String properties to a message in a JMS destination

Hi,
I've been able to successfully connect to my openMQ broker with the JMS Writer destination and send a TextMessage and I'm trying to understand how I can add a string property to the sent message?
(i.e. the receiving end will be able to do msg.getStringProperty("keyIEntered") and receive that value).
I have a hunch that this can be acheived in the postprocessing scripts but I'm not really sure.
Has anyone done that?
If so I'd really appreciate learning how.

Thanks in advance,
Ittai
Reply With Quote
  #2  
Old 08-24-2011, 10:20 AM
Bostad Bostad is offline
Level 85 Channel Wizard
 
Join Date: Mar 2009
Location: Stratford Ontario
Posts: 712
Bostad is an unknown quantity at this point
Default

Hi;

Anything done in your post processor will happen after your message has left Mirth, so you need to do this in your destination.

I've never tried, but does the .setStringProperty method work? I've seen a reference to it in the Mozilla documentation.
__________________
I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
http://www.linkedin.com/pub/david-rothbauer/5/923/518
codeismydrug.wordpress.com
hl7coders.wordpress.com

Test all my code suggestions prior to implementation
Reply With Quote
  #3  
Old 08-25-2011, 12:59 AM
Ittai Ittai is offline
What's HL7?
 
Join Date: Aug 2011
Posts: 5
Ittai is on a distinguished road
Default

Hi,
Thanks for your reply (I wasn't sure how active the community is).
I see what you mean about the postProcessor and so I went to the destination and added a step in the transformer of the JavaScript type.
There I tried both:
Code:
message.setStringProperty('testKey','testValue');
and
Code:
message.setStringProperty("testKey","testValue");
And after placing a message I received the following error:
Code:
ERROR 2011-08-25 08:48:13,282 [cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_source_connector._fileEndpoint#508194636.receiver.1] org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in Exception Strategy for: cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5: org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.mirth.connect.model.MessageObject
org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.mirth.connect.model.MessageObject
	at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:84)
	at org.mule.impl.model.DefaultMuleProxy.onCall(DefaultMuleProxy.java:247)
	at org.mule.impl.model.seda.SedaComponent.doSend(SedaComponent.java:209)
	at org.mule.impl.model.AbstractComponent.sendEvent(AbstractComponent.java:277)
	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:201)
	at org.mule.routing.inbound.InboundMessageRouter.send(InboundMessageRouter.java:176)
	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:143)
	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.file.FileMessageReceiver.processFile(FileMessageReceiver.java:228)
	at com.mirth.connect.connectors.file.FileMessageReceiver.poll(FileMessageReceiver.java:118)
	at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97)
	at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.mule.umo.routing.CouldNotRouteOutboundMessageException: Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@459c4bd0, endpointUri=jms://CE_Fake, transformer=Transformer{name='cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_destination_2_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_jmsEndpoint#1652802880', type='sender', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@7449507c, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.mirth.connect.model.MessageObject
	at org.mule.routing.outbound.FilteringMulticastingRouter.route(FilteringMulticastingRouter.java:72)
	at org.mule.routing.outbound.OutboundMessageRouter$1.doInTransaction(OutboundMessageRouter.java:78)
	at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:48)
	at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:82)
	... 16 more
Caused by: org.mule.umo.provider.DispatchException: Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.jms.JmsConnector@459c4bd0, endpointUri=jms://CE_Fake, transformer=Transformer{name='cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_destination_2_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_jmsEndpoint#1652802880', type='sender', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@7449507c, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.mirth.connect.model.MessageObject
	at org.mule.providers.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:177)
	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:191)
	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:130)
	at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:85)
	at org.mule.routing.outbound.FilteringMulticastingRouter.route(FilteringMulticastingRouter.java:54)
	... 19 more
Caused by: org.mule.umo.transformer.TransformerException: 
CHANNEL:	mock sender
CONNECTOR:	Destination 2
SCRIPT SOURCE:	
SOURCE CODE:	
5: msg = new XML(newMessage);
6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
8: 
9: 
10: message.setStringProperty("testKey","testProperty");
11: 
12: }
LINE NUMBER:	10
DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>. (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.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
	at com.mirth.connect.server.controllers.DefaultMessageObjectController.getMessageObjectFromEvent(DefaultMessageObjectController.java:785)
	at com.mirth.connect.connectors.jms.JmsMessageDispatcher.dispatchMessage(JmsMessageDispatcher.java:85)
	at com.mirth.connect.connectors.jms.JmsMessageDispatcher.doSend(JmsMessageDispatcher.java:252)
	at org.mule.providers.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:164)
	... 23 more
Caused by: org.mule.umo.transformer.TransformerException: 
CHANNEL:	mock sender
CONNECTOR:	Destination 2
SCRIPT SOURCE:	
SOURCE CODE:	
5: msg = new XML(newMessage);
6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
8: 
9: 
10: message.setStringProperty("testKey","testProperty");
11: 
12: }
LINE NUMBER:	10
DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>. (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)
	... 30 more
Caused by: com.mirth.connect.server.MirthJavascriptTransformerException: 
CHANNEL:	mock sender
CONNECTOR:	Destination 2
SCRIPT SOURCE:	
SOURCE CODE:	
5: msg = new XML(newMessage);
6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
8: 
9: 
10: message.setStringProperty("testKey","testProperty");
11: 
12: }
LINE NUMBER:	10
DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>.
	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:398)
	... 31 more
I'm not sure what you mean by the Mozilla documentation?

Thanks again for your help

Last edited by Ittai; 08-25-2011 at 02:03 AM. Reason: Typo
Reply With Quote
Reply

Tags
jms, propery, script

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 02:49 AM.


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