Exception in BizTalk with Two-Way receive port direct binding - biztalk

I have the same problem as described here:
I am using two orchestrations. First orchestration calls the second using direct binding through a two-way send port. Second orchestrion has a two-way receive port to send the result back to the first. Every thing is working as it should but I am getting the following exception.
A response message for two-way receive port "Unknown " is being suspended as the messaging engine could not correlate the response to an existing request message. This usually happens when the host process has been recycled.
And the suggested solution works as well (set the BTS.EpmRRCorrelationToken value to a random value, new GUID in my case, in the first orchestration before send to the direct binding port and then in the secod orchestration i copy the value from the inputMessage to the outputMessage, so the value remains the same. With this method BizTalk knows how to correlate the response back to the caller). But I can't understand why this works and if this a good way to solve the problem. The BTS.EpmRRCorrelationToken flow is the following:
When I don't change the BTS.EpmRRCorrelationToken property, it is the same in all messages which flow in the process, but why on Earth doesn't BizTalk change it instead if it can't correctly correlate the messages?

Changing this property is certanly OK in your case.
The problem is direct binding. When you use it, you actually going more "low-level" way and have to deal with how BTS publish-subscribe mechanism works.
Send-Receive port subscribes to receive a message with a specific BTS.EpmRRCorrelationToken. So when you post receive message again in the Message box (for second orch), receive port grabs it too and unsubscribes then. When you finally try to send a response - there is noone waiting for it. So you have to change that property until you sending response back to the port.

Related

BizTalk - how to subscribe to two-way send ports response, but access data from the request

I need to submit something to a web service, then I need to send something over MLLP using the HL7 MLLP adaptor and the message needs to contain something returned by the service, and something that was sent to the service, and I'd like to use a pure messaging solution if possible, not an orchestration.
So basically I have two send ports. The second needs to subscribe to the response of the first, which means that it's message will the the first send ports response.
The trick is I also need some data from the first send ports request message. Is it possible to get that somehow?
The correct way to do this is use an Orchestration.
There is nothing wrong with using an Orchestration, and Orchestrations exist exactly for this purpose.
If someone is telling you Orchestrations are not right or you've read that somewhere...they're wrong. That's it. If you're having problems using Orchestrations...telling you straight up, you're doing it wrong.
In an Orchestration, you can probably use a Map to merge the content into the service response. Exactly the use case it's meant for.
Here's a started Suspend/Resume pattern: BizTalk Server: Suspend and Resume an Orchestration on Two Way Port Error
You have no control of this in a Messaging only solution.

BizTalk: BTAHL72XReceivePipeline Pipeline Component

I've set-up two applications, one with FILE Receive Port and the other with a Send Port subscribing to that Receive Port with filter set as BTS.ReceivePortName == {ReceivePortNameHere}. I'm using BizTalk 2013 R2.
In the Receive Port, I'm using the pipeline 'BTAHL72XReceivePipeline'. And, in the Send Port, I'm using the pipeline 'BTAHL72XSendPipeline'.
When I drop a HL7 message into the Receive Port file location, it produces the error:
The Messaging engine failed to process a message submitted by
adapter:FILE Source URL:E:\InboundToBizTalk\*.hl7. Details:The
published message could not be routed because no subscribers were
found. This error occurs if the subscribing orchestration or send port
has not been enlisted, or if some of the message properties necessary
for subscription evaluation have not been promoted. Please use the
Biztalk Administration console to troubleshoot this failure.
However, I do have a subscription set. Why is this error occurring? Is there an issue with the pipeline component or the way I am using it?
On the Group Overview page search for "Subscriptions" and filter based on your Send port name.
Verify that you see an activation Subscription and confirm that the filter conditions on the subscription are correct.
The by far most likely causes:
A typo between the Receive Port Name and the value in the Filter.
The Send Port is not Enlisted or Started.
Do not use quotes in the filter property.
Turned out to be ACK which could not be routed therefore causing the whole flow to error. For an MLLP transport type, it is two way thus the ACK can be routed. For a FILE transport type, it is one way therefore ACK needs to be accounted for separately.
To get around this, another port was created which would subscribe to the ACK.

XML message not transformed using orchestration once application is deployed

The xml messages coming out of my send port do not reflect my orchestration used to transform the message.
Although I tested the message map and observed the expected transformation of XML, I am confused on how to test the orchestration that uses the map.
The orchestration has the following:
ReceiveMessage
ConstructMessage => Transform
SendMessage
After I deployed the Biztalk application and provided source messages to the instance, I observed that the messages coming off the send port still do not reflect the expected transformation. Instead, these messages have the same format as the source XML schema.
NOTE:
I am learning Biztalk.
I have stopped and restarted the server instance within the Administration Console.
If this is the first time you have tried this, it's probably because the Message isn't making trough the Orchestration because the Ports aren't Bound properly. Make sure the Deployed Orchestration is Bound to the right Receive Port and Send Port (and Host) and Enabled.
If you're using PassThruReceive then I suspect that you have some other filter set for your Send Port and that your Orchestration is not even instantiating. Try using the XmlReceive pipeline. This will run the XmlDissasembler mentioned above which will read the namespace and root node and publish the message to the message box.
I suspect that you are subscribing in your Orch by message type, in which case, will pick up the message. When this happens, if you get 2 messages output, then you do indeed have another filter on your send port.

BizTalk sends infinite copies to destination folder

I have an orchestration which sends a message A to message box. Now I have 2 subscriber orchestrations which subscribe to the message based on a filter expressions.
Now when I send a message which is to be routed to Subscriber 1, everything works fine, but when a message for subscriber 2 is sent it is routed to destination folder but infinite copies are created in the destination folder. I have to stop the orchestration to stop the generation of duplicate copies of message.
What am I doing wrong?
Are you receiving the same message that you are sending? If so this will cause an infinite loop because your receive location will pick the message up when it is sent. You need to change the filter on the receive, set a flag in your message in the orchestration and then filter on that perhaps.
This is often a symptom of a feedback loop, i.e. where you have a situation like:
Implementing a receive port which listens to the location that a send port publishes messages.
Implementing a direct-bound orchestration with a send port configured to publish messages to the message box of the same schema that it receives (without any filtering)
This is especially common in direct bound (MessageBox) scenarios, as this doesn't have the additional filters which are applied with Specify Now / Later settings. The solution is usually to add an additional filter - either out of the box, such as BTS.ReceivePortName, or a custom context property) on subscribers, so that you can distinguish between messages which have already been processed.

How to subscribe to messages created in a BizTalk orchestration?

I have an orchestration that takes a message. The target namespace is "http://microsoft.com/HealthCare/HL7/2X" and the root element is "ORU_R01_23_GLO_DEF"
In the orchestration, I map the message to an intermediate message type in a construct shape. The target namespace is "http://mycompany.com/myapplication" and the root element is "MyMessage". The "MyMessage" message is then further mapped and then sent to a web service using a logical send port in the orchestration. A WCF send port is then bound to the orchestration and everything works fine. Everything works as expected.
Without altering the orchestration, I want to create a send port that subscribes to the intermediate "MyMessage" message and writes it to a file. To do this, I have created a send port with a filter of BTS.MessageType = http://mycompany.com/myapplication#MyMessage.
Even though messages are flowing through the orchestration, my send port isn't picking up the message. Is this the incorrect filter to use?
Are you trying to subscribe to the 'MyMessage' message, or the same message that is sent to the logical Send Port bound to the physical WCF Send Port?
You have stated that:
The "MyMessage" message is then further mapped and then sent to a web service using a logical send port in the orchestration. A WCF send port is then bound to the orchestration and everything works fine.
Message not Published to MsgBox
From what you have described, I would suggest that you do not have a Send Shape/Logical Send Port combination in your orchestration for the 'MyMessage' message, which is why you can't manually subscribe to this message type in a Send Port filter. The fact that you have not mentioned a 'Failed Routing Report' message further suggests that this is the case - this message type is generated when no subscriotion can be found for a message that is to be published to the MsgBox.
Capture a Message's 'MessageType'
If however you need to capture a copy of the message your are sending over the WCF Send Port, you will need to determine its MessageType and use that in your second Send Port subscription that writes the message out to file.
If you are unsure as to what MessageType to use, there is a simple trick to determine this information:
Stop (not Unenlist) the WCF Send Port
Send a message through your orchestration as normal - the message will be marked as 'Suspended Resumable' in the BizTalk Admin Console on the WCF Send Port.
Open the message in the BizTalk Admin Console and view its 'Message Context'; in the Message Context you will see its 'MessageType' property which you can then use to understand which subscription filter to use.
Start the WCF Send Port to flush the message.
Alternatively, if you don't want to change your orchestration, you could try archiving your message as it passes through the Send Pipeline in the (original) WCF Send Port - either write your own archiving component or use an existing commercial component. By using an archiving component in this manner, you will save yourself the expense of an extra subscription and the associated Send Port maintenance.
Update:
It sounds very much like the OP is not sending the intermediate message to the Message Box from their Orchestration (see comments). Message subscription will only work when a message is published to the Message Box - in this case, the message in question ('Message B') is an intermediate message that only lives within the context & lifetime of the orchestration. The OP needs to Send the message to a Direct Bound port within the Orchestration to allow the message to be subscribed to via a Send Port.
Verify the pipelines of the Send Port. Should by XML, not Passthrougth.

Resources