Unable to receive message from WEB-SPHERE MQ queue by using Citrus Frame work xml test cases - citrus-framework

I am trying to receive messages from web-sphere mq queue by using citrus framework by defining actions in XML-test-cases. as shown below.
<receive endpoint="jms:Queue_Name?timeout=1000">
<selector>
<element name="correlationId" value="303132333435363738393130313131323133313431353136"
</selecotr>
<message>
</message>
</receive>
I tried mentioning correlation id with hexadecimal value and ASCII value but I am unable to get the message I am getting ACTION TIME OUT EXCEPTION. I cross checked correlation id that existed in WEB-SPHERE MQ with mentioned correlation id in xml. but without selector tag I am able to get the message that was inserted first in the queue based on time.

You have to give correlation ID value like this it will work for you
<receive endpoint="jms:Queue_Name?timeout=1000">
<selector>
<element name="correlationId" value="ID:${varible consisting og hexa value}"
</selecotr>
<message>
</message>
</receive>

Related

How to allow and parse FIX message with QuickFIX if Field 55 appears multiple times in FIX incoming message?

This particular broker does not provide a DataDictionary so I have to create my own based on their documentation.
This is how they send a particular message:
FIX.4.4|9=709|35=y|34=53|49=DUMMYBROKER|56=<client_ID>|52=20210211-
12:12:37.358847|55=AUD/CAD|55=AUD/CHF|55=AUD/JPY|55=AUD/NZD|55=AUD/USD|55=
CAD/CHF|55=CAD/JPY|55=CHF/JPY|55=EUR/AUD|55=EUR/CAD|55=EUR/CHF| ...
etc
How can I allow QuickFix a field to appear multiple times?
Once I recieve the message what is the best way to read it? I am using QuickFIX/n.
This would probably provide me the last symbol only:
var symbolstring = message.GetString(Tags.Symbol);
This is how the SecurityList is defined in the DataDictionary:
<message name="SecurityList" msgtype="y" msgcat="app">
<group name="NoMDEntries" required="Y">
<field name="Symbol" required="N"/>
</group>
</message>
I have tried changing "Y"/"N" in all variations, but it still cannot absorb the message properly.
This message is invalid FIX, and is simply not parseable by QuickFIX/n (or any QF engine).
A repeating group must start with a counter field which tells the receiver how many instances of that group will follow. Their message doesn't have that counter field.

How to get MAM message ID of sent messages?

I am using eJabberd server (MAM enabled) with client library Strophe.js. Client app is storing fixed amount of the messages in local storage.
All the messages, that I receive from the server include elements <archived/> and <stanza-id/>, which provide server-side generated IDs:
<message
xmlns="jabber:client" to="aaa#example.net/8667085700924567016834" from="aaa#example.net">
<result
xmlns="urn:xmpp:mam:2" id="1520510373346685">
<forwarded
xmlns="urn:xmpp:forward:0">
<message
xmlns="jabber:client" xml:lang="en" to="bbb#example.net" from="aaa#example.net/60965696931000870402419" type="chat">
<archived
xmlns="urn:xmpp:mam:tmp" by="aaa#example.net" id="1520510373346685"/>
<stanza-id
xmlns="urn:xmpp:sid:0" by="aaa#example.net" id="1520510373346685"/>
<body>asdf</body>
</message>
<delay
xmlns="urn:xmpp:delay" from="example.net" stamp="2018-03-08T11:59:33.346685Z"/>
</forwarded>
</result>
</message>
I use these IDs to get fixed amount of messages on each MAM call (using RSM paging - before/after/max attributes). For example:
params = {
"before": "1520510373346685",
"max": 10,
onMessage: <some handler>,
onComplete: <some handler>,
}
this.connection.mam.query(Strophe.getBareJidFromJid(this.myJid), params);
This gets me 10 messages before the message with stanza-id 1520510373346685.
However, the messages I send inherently do not have this ID, until I send them and retrieve from MAM.
I did not find any examples on getting the currently sent message ID from the server, and the Strophe does not provide any callbacks after the message was sent from the client and received by the server.
So, the question - is there any way to get the server-generated message ID (stanza-id/archived) for the currently sent message?
Maybe my own approach is wrong - should I generate my own IDs and add it to each message from the client?
There is currently no mechanism specified besides querying the archive. One prominent idea within the XMPP community to solve this in the future is to reflect the send carbon back to the original sender, which would include a stanza-id element with the ID assigned by the archive.

Simultanous sending and receiving

I am trying to send and receive message to and from JMS topics.
<testcase name="DeliveryToPT3PLIT">
...
<actions>
...
<send endpoint="fromEndpoint">
<message>
<resource file="com/roche/icc/citrus/messages/input/PT-3PLWoBatchSplit.xml"/>
</message>
<header>
...
</header>
</send>
<receive endpoint="toEndpoint">
<description>Receive asynchronous message from topic</description>
<message>
<resource file="com/roche/icc/citrus/messages/output/PT-3PLWoBatchSplit.xml"/>
</message>
<header>
...
</header>
</receive>
</actions>
</testcase>
It seems that these operations go one after another. The problem is that my application works really fast and when I send a message to first topic it appears on "toEndpoint" almost immediately. So the receive operation does not manage to catch appropriate message since it has been already processed.
Is there any way to make this operations simultaneously?
Regards
There is one thing to note about using JMS topics, because they work in a publish/subscribe manner, you have to subscribe first in order to receive the message.
That means you need to subscribe to the topic before a message is going to be published. Also, if you say that your application is fast, you may need to wait a few millis before sending the message. Here is a Java DSL example of what I think may work for you. (Note: I have tested this example with a JMS topic)
parallel().actions(
sequential().actions( // Thread #1
...
receive(action -> action.endpoint(toEndpoint).payload("message to be received"))),
sequential().actions( // Thread #2
sleep(500),
send(action -> action.endpoint(fromEndpoint).payload("message to be sent"))));
Notice the parallel() action container. It will execute every action inside it in a separate thread. Each sequential() represents a series of actions that allows you to group them together. Because both sequential() containers are inside the parallel(), the actions inside each of them will be executed on different threads.
So what happens here: you split your actions on two threads. On the first thread you wait for a message. On the second thread, you make it sleep for 500 millis first, after which you send the message.
I'm sorry that I don't have an XML example, but I hope this helps anyway.
Also don't forget to set the pub-sub-domain property to true on your endpoints. See the Citrus documentation on JMS topics: here.

Getting Json error while using #variable()# matcher

I have a scenario where particular response data has to be used in the next request.
I used payload("{\"alarmName\":\"#variable('apiVersion')#\"}") But the execution is failing with exception. Below is the exception message.
{"__v":0,"minVal":18,"alarmName":"TempAlarm7","_id":"59d50f49e877251d1eea592d"}
Number of JSON entries not equal for element: '$.', expected '1' but was '4'
Any idea how to resolve it?
Regards
Geeks
This is because your actual Json message has multiple elements (__v, minVal, alarmName and _id). Your control Json message just defines the element alarmName. Citrus Json message validator is using this strict mode by default so it will count and check that all elements are defined in expected control Json message. This is why you get the error.
Two options here. Either add all missing elements in control Json message with #ignore# value or disable strict mode in Json message validator. Second option can be done by overwriting the Json message validator bean:
<bean id="defaultJsonMessageValidator" class="com.consol.citrus.validation.json.JsonTextMessageValidator">
<property name="strict" value="false"/>
</bean>

Order of unbounded elements in xmlschema sequence

I'm currently developing an application that uses webservices (SOAP 1.2). I'm interested in knowing if I can rely on the order of unbounded elements in a xmlschema sequence. Here is my definition of that sequence in the wsdl I'm using.
<xsd:complexType name="IdList">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="id" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
Does that give me any kind of guarantee on the order of the elements? Say this is an excerpt of the associated soap message:
<web:globalRecipientIds>
<!--Zero or more repetitions:-->
<web:id>1</web:id>
<web:id>15</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
Does that mean that the receiving end will treat it in the order that it appears in the SOAP message? Is this something that depends on the implementation of the receiving end? If it does, I generated the receiving end using wsdl2java from apache axis to generate the java code from the wsdl file. Can you tell me something specific about this?
The order of XML elements is significative - regardless of the schema - e.g.
<web:globalRecipientIds>
<web:id>1</web:id>
<web:id>15</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
and
<web:globalRecipientIds>
<web:id>15</web:id>
<web:id>1</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
are two different XML, and XML tools (should) preserve and recognize the order of elements.
Having said that, this does not guarantee that 'the receiving end will treat it in the order that it appears in the SOAP message' - depends on what the receiving end does with the XML. It receives an ordered list of ids, but if (for example) puts those ids in a dictionary or some other hashed structure the order is lost.