Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Let's go over some of the out-of-the-box options for executing a pipeline from inside your orchestration.
 
It struck my mind first that the MSMQT adapter IS in fact the messagebox.
 
  1. MSMQT
 
  • Set up a schedule with 1 MSMQT send port and 1 MSMQT receive port sharing the same MSMQT queue name (for example ' loopback' would make a lot of sense)
  • Create a correlation type and set based on the my MSMQT label property.
  • Assign the MSMQT message-label to a newly created GUID inside your orchestration.
 
Try to do a send and a receive and you will see that your pipelines will be executed. As a test I could successfully parse a message from inside a schedule.
 
Another very simple option is using the HTTP adapter, credits go 100% to Scott Colestock. Scott used this as just a temporary approach to get past this problem, and then switched to the loopback adapter below...
 
  1. HTTP
 
  • Use a solicit-response send port 
  • Use bogus HTTP page that simply echoes the content back.
 
<% @ webhandler language="C#" class="LoopbackHandler" %>
using System;
using System.Web;
using System.IO;
public class LoopbackHandler : IHttpHandler
{
   public bool IsReusable
   { get { return true; } }
  
   public void ProcessRequest(HttpContext context)
   {
      using(StreamReader sr = new StreamReader(context.Request.InputStream, true))
      {
         StreamWriter sw = new StreamWriter(context.Response.OutputStream, sr.CurrentEncoding );
         sw.Write(sr.ReadToEnd());
         sw.Flush();
         sw.Close();
      }
   }
}
 
This can be easily explained because it requires no knowledge of correlation types and correlation sets, since you are using request/response ports the whole way. If simplicity is the main goal then this solution is probably superior to the MSMQT one.
 
  1. Custom LOOPBACK Adapter.
 
I also had another idea. Why not make your own loopback adapter by writing a bogus solicit-response adapter that returns a response BizTalk IBaseMessage that is a copy of the original request message. Recreate the original individual message-parts and copy of the request stream to the response stream. It's very simple - download my sample loopback adapter here.
 
  • It's a custom coded VB.NET non-batched but non-blocking (async) adapter that really doesn't do anything.
  • Uses limited memory-footprint, streams to disk. 
  • To install use the MSI package. Don't forget to add the adapter by using BizTalk administration...
  • It auto generates the transmit location URI (in fact it's a GUID). I also added a Boolean property to specify whether you want the original message and part properties to be copied on to the response-message and parts.
 
Here are some of the benefits:
 
  • Trigger pipeline execution from inside your orchestration. Just define your outbound and inbound pipelines and they will be executed.
  • Send pipeline errors can be catched by adding a deliveryfailure-exception handler. Also adapter exceptions can be catched there, but since this adapter really doesn't do anything this will be very rare (at least I hope so).
  • Receive pipeline errors can be catched by adding a general SOAP-exception handler.
  • Execute mappings from inside your orchestration by defining a map on the inbound and outbound port. When you use the later, mapping failures will be catched by the SOAP-exception handler.
  • It's a black-hole adapter if you want. It can be used to ignore the processing of certain incoming messages. Make a send-port, name it 'VANISH' and subscribe to a given message-type or receive-port name for example.
  • It's very useful for doing in-order processing. You can for example receive messages from MSMQT through a pass-through pipeline (which is recommended BTW) and process messages in-order from start-to-end while doing exception-handled parsing/validation/mapping by implementing a serial convoy.
 
Here's a sample project that demonstrates some of the benefits.
 

Remarks:
 
  • The code can definitely be improved. It has been written very quickly in the scope of a POC. Alternatively you could make a better one using the adapter base classes and the wizard. In fact I'm hoping the community will see the benefit of this loopback adapter and someone else will make a better one. I'm not (yet, ha!) a streaming and multi-threading expert.
  • Apparently it is advised to return a read-only forwarding stream to the receive-pipeline. At least until SP1 arrives. I just used the VirtualStream class from the BizTalk Streaming assembly.
  • Do not forget, and as usual: there's no warranty at all. I haven't tested this very thoroughly yet so…use the adapter at your own risk.

Print | posted on Wednesday, November 10, 2004 3:24 AM

Feedback

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Kurt at 11/11/2004 8:34 PM
Gravatar Could you not just send the message to the MsgBox via a direct port and receive it back?

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Grego at 11/12/2004 2:13 PM
Gravatar I need to do some additional testing with direct ports, also with self-correlating ones. I'm not sure if direct 'messagebox' ports enable me to define the send pipeline and whether errors can be catched. I doubt if the result will be as easy to use as the HTTP or a LOOPBACK adapter...

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Kurt at 11/14/2004 11:32 PM
Gravatar I checked it out and there doesn't seem to be a way to put pipelines on the direct ports.

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Grego at 11/15/2004 5:24 PM
Gravatar That's what I already expected. Anyway: thank's for sharing...

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by J S at 1/27/2005 12:05 AM
Gravatar any ideas on how to resolve this error:

"no service organization tree. the adapter returned a null value"

I get this error after installing the loopback adapter, and then when I try to add autogenerated items -> add adapter -> Loopback -> hit next and a dialogue box pops up with the error mentioned above.

Any ideas on how to resolve this?

Thanks in advance!

-JS

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Grego at 1/27/2005 9:39 AM
Gravatar JS,

This adapter does not support generated items (since there are no schema's to be generated anyway). Why would you want to do this?

Regards,
Gregory

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by J S at 1/27/2005 7:51 PM
Gravatar How would I go about using this? How can I add this to my orchestration?

a lil confused..

-JS

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Grego at 1/28/2005 2:24 PM
Gravatar In the orchestration you can create a (send) port-instance of port-type "Request/Response". Create a static solicit-response (SEND) port using the BizTalk explorer with transport-adapter type LOOPBACK. Next bind your orchestration to this port. That's all pretty basic stuff...

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by Hendrik Swanepoel at 10/10/2005 2:42 PM
Gravatar I tried using the loopback adapter, using a flat file assembler in the send pipeline. I tested the pipeline with a send only port and it outputs the correct string.

When I try and configure the port using the loopback adapter to return a message of type string (which I thought it would be, seeing that I used the flat file assembler) it gives me an error: Received unexpected message type '' does not match expected type 'string'.

I checked the message when I do not use the flat file assembler in the send pipeline, and it then returns the correct XML.

Do you perhaps know what message tpe I should be working with?

Much appreciated.

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by DB at 10/31/2005 7:24 PM
Gravatar Can an Loopback adapter be used to hack your computer?
I have ZoneAlarm Pro and I never installed a Loopback adapter but now I have one. My computer seems to behave normal. My download uploade meter shows no unusual activitie.
If I set my Loopback adapter to 'blocked' in ZoneAlarmPro is can not acces internet.

My tech-level is newbie. ;-)
I am just capable of installing XP and installing a firewall program and internet.

Thanks for replying.

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by DB at 10/31/2005 7:33 PM
Gravatar From TechGuy forum. Should have browsed longer

Q: What is a loopback adapter and what does it do for a computer?

A: Loopback is used for testing or debugging problems. Loopback simply means that data sent out will be delivered back to the source (usually without actually going across a network). Either protocol software or network hardware can provide loopback, depending on what one needs to test. For example, pinging address 127.0.0.1 causes the IP software to test loopback by handing the datagram back to ICMP on the same machine.
_________________________

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by jimg at 11/8/2005 6:01 PM
Gravatar hello, i am using the adapter you created. I like it. I need to verify some issues I am having with the encoding bytes on the incomming message.

Can I have your current solution please?

escuber@hotmail.com

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by horochj at 1/30/2006 8:01 PM
Gravatar Can you post your source code for the loopback adapter on this site ? or email me a copy ?

horochj@yahoo.ca

Thanks

# Whatif i block the loopback in zalarm

Left by sobadhy at 3/27/2006 11:23 PM
Gravatar read the topic

# Loopback dropping French Characters

Left by horochj at 7/27/2006 1:26 PM
Gravatar I've been using the loop back adpater for a while, but have noticed a problem with French characters. The send pipeline is just the standard pass through, but the receive pipeline is a schema using code page ( western european 1252 ). The document goes in with the French characters, but when the xml comes out the characters are gone. Any ideas ?

# re: Need the source code of the adapter

Left by Karthick at 12/22/2006 7:52 AM
Gravatar Hi,
i am in need of the source code of this adapter.
My Problem line is the send port will send out a xml with a element having the flatfile data and i need that to be disaasembled in the receive side.so in the adapter i need to get the particular element value which is having the flat file data from IBaseMessage Data Stream and put that back into the IBaseMessage Data stream.

I think you can understand the issue,Please its very urgent,
Please mail me the source code at karthickg@gmail.com
or please give a URL of the source code.

Thanks and Regards,
Karthick G.

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by pandu at 4/17/2007 9:07 PM
Gravatar i want to use receivefile name inside orchestration.
How can i used ?
As the file name will contain the type of operation to be done.
e.g.
EmpInsert.txt ----perform insert operation

Thanks and Regards,
Pandurang

# re: Executing pipelines from inside an orchestration: Introducing the LOOPBACK adapter

Left by BVeldhoen at 8/7/2008 11:56 AM
Gravatar Hi Gregory,

You have posted a link to the LoopbackAdapter.msi. Is it also possible to provide the source code for this loopback adapter?

Many thanks,
Bram.

Your comment:





 
Please add 2 and 8 and type the answer here:

Copyright © Gregory Van de Wiele

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski