cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the JMSCorrelationID

Former Member
0 Kudos

In our scenario we receive an IDoc and transform it into an XML-Message which is transmitted by an JMS Adapter.

The IDoc includes an unique value which we have to use as the JMSCorrelationID.

How can I select this specific value of the message for the JMSCorrelationID?

Due to performance reasons I can't work with a BPM. I can only work with mappings assisted by java methods.

Thanks for your help

Dirk

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

as far as I understood the article in the library, I can take a value of the XI-Message-Header as JMSCorrelationID.

The question now is, how I can set a value (e.g. XIMessageID) in the XI-Message-Header?

Are there an restrictions concerning the JMSCorrelationID. So can this ID be an int-Value?

I already tried to set the Message-ID by the following user-defined function in the mapping:

java.util.Map map;

map = container.getTransformationParameters();

String result = (String) map.get(StreamTransformationConstants.MESSAGE_ID);

map.put(StreamTransformationConstants.MESSAGE_ID, "123456");

return (String) map.get(StreamTransformationConstants.MESSAGE_ID);

Depending on the JMS-Adpater-Settings the JMSCorrelationID of JMS-Message is either NULL, an empty String or an hex-value. But I never got 123456 as JMSCorrelationID.

Regards

Dirk

Former Member
0 Kudos

Hi Dirk,

is your ultimate goal to set the JMS Correlation ID to a value that is in the Payload of your message?

If this is the case I recommend you use the Adapter-Specific Attributes of the JMS Adapter and a little Java Mapping that sets the value (to be included right after the Message Mapping in the Interface Mapping that maps your IDoc to something else).

See the following links for more information on Adapter-Specific Attributes:

http://help.sap.com/saphelp_nw04/helpdata/en/10/b1b4c8575a6e47954ad63438d303e4/frameset.htm

The attribute that you need to set is <b>DCJMSCorreleationID</b>

and the instructions for the required Java Mapping (which can also be in a User-defined function) are here:

http://help.sap.com/saphelp_nw04/helpdata/en/43/09b16006526e72e10000000a422035/frameset.htm

Good luck - all other methods had their little problems, I found this one the most appropriate and reliable way of setting the JMS COrrelation ID.

regards,

Peter

Former Member

Answers (4)

Answers (4)

Former Member
0 Kudos

To print out the content of a hashtable use some code like this:

String name, value;

for (Enumeration e=mp.keys(); e.hasMoreElements();) {

name = (String)e.nextElement();

value = (String)mp.get(name);

// this is used in Adaptermodules to append XML-Tags

Element childElement = document.createElement(name);

childElement.appendChild(document.createTextNode(value));

rootNode.appendChild(childElement);

}

If you do not use this in Modules you can certainly print the values:

System.out.println("Parametername: " + name + " Parametervalue: " + value);

Hope this is helpful.

Former Member
0 Kudos

Hi everybody,

thank you for your support. Now it works.

I'm using a user-defined function, like

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/JMS", "DCJMSCorreleationID");

conf.put(key, messageId);

where messageId is a parameter of the function which has the attribute value of the payload.

Furthermore I checked the adapter-specific message attribute CorrelatonID.

Dirk

former_member184154
Active Contributor
0 Kudos

Guys, nobody will care probably, but after strugglin' for while I found that the right combination is given by:

<SAP:DynamicConfiguration SOAP:mustUnderstand="1">

<SAP:Record namespace="JMS" name="DCJMSCorreleationID">4D692810A87811DA96D30003BAE00517</SAP:Record>

</SAP:DynamicConfiguration>

Former Member
0 Kudos

Right, but the Namespace is 'JMS' only if you are using SP14 - with SP15 this bug was fixed and it now has to be

http://sap.com/xi/XI/System/JMS

tricky bug in SP14 - I made SAP aware of that in an OSS message and they fixed it with SP15 which made all my nice functions fail suddenly

regards,

Peter

former_member184154
Active Contributor
0 Kudos

Thanks for the hint, Peter!

That's how I secured my SP14 code in case of an upgrade

(<i>It's just one of the function module behind SPAM</i>)

  DATA: jmscorrid TYPE mpp_dynamic,
        ts TYPE string,
        components TYPE TABLE OF spam_cvers,
        component TYPE spam_cvers.
  CALL FUNCTION 'OCS_GET_INSTALLED_COMPS'
    TABLES
      tt_comptab = components.
  READ TABLE components WITH KEY component = 'SAP_BASIS' INTO component.
  IF component-extrelease = '0014'.
    JMSCORRID-NAMESPACE = 'JMS'.
  ELSE.
    jmscorrid-namespace = 'http://sap.com/xi/XI/System/JMS'.
  ENDIF.
  jmscorrid-name = 'DCJMSCorreleationID'.
  CONCATENATE 'ID:' sy-datum sy-uzeit INTO ts.
  jmscorrid-value = ts.
  dynamic_configuration->add_record( record = jmscorrid ).

Cheers,

Alex

Former Member
0 Kudos

Interesting, but how do I do it in a Java mapping or a XI Module in the Module Processor. The effort to access the components table (maybe via Mapping lookup API, or JCo) seems a little too high for that purpose...

anyway thanks for the hint

regards,

Peter

Former Member
0 Kudos

Hi Alessandro,

Your post was really useful, I had a similar issue which now I could set the JMSCorrelationID to my desired value.

Thanks for sharing

Cheers,

Jodie

Former Member
0 Kudos

Hi Dirk,

I am using a field out of the payload and map it into the XI Conversation ID which you can use in the JMS Config as one of the fields.

I have done this in a module bean wich I call before the standard SAP module chain.

One thing which is very important is that you put ID: in front of the id you want to use. Otherwise the JMS correlation ID gets destroyed if you use non-ASCII characters in as JMS correlation ID. MQ does that in our case.

Cheers

Stefan

Former Member
0 Kudos

hi

Can you tell me how to get the JMS status payload..

try {

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

// Get the Supplemental Data which is available as Hashtable

Hashtable mp = (Hashtable)inputModuleData.getSupplementalData("module.parameters");

//print the Hashtable contents

System.out.println("printing hash table");

System.out.println(mp);

//get the file name which is being processed

if(mp!=null)filename =(String)mp.get("FileName");

will this work?

Thanks-GS

Former Member
0 Kudos

Hi,

The links below will help you Configure the Sender and Receiver JMS Adapters…..And the links below will also answer your questions regarding the JMS CorrelationID.

Configuration of the Sender JMS Adapter:

http://help.sap.com/saphelp_nw04/helpdata/en/f4/2d6189f0e27a4894ad517961762db7/content.htm

Configuration of the Receiver JMS Adapter:

http://help.sap.com/saphelp_nw04/helpdata/en/10/b1b4c8575a6e47954ad63438d303e4/content.htm

Regards,

Abhy