Send Single File to different location through custom disassembler - biztalk

I am getting a file in receive location and I want to send that file to a repository location as well as want to save that file in database ? I want to done this through custom disassembler ?
Please provide any useful link by which I can get my requiremnet.

BizTalk has a publish-subcribe architecture, which means that whenever something is published to the message box, you can use 1-N subscribers.
This means the easiest scenario would be to use two send ports:
One to send the file to the repository location (FILE adapter)
One to send the file to the database (WCF-SQL adapter or in case of BizTalk 2006 R1, the SQL adapter)
Both would subscribe to the same input message and would need a different outbound map on their send port to map to the correct schemas for your needs.
The subscription is the send port filter, where you can either point to the receive port (BTS.ReceivePortName although this is not a good practice) or to the BTS.MessageType (better approach).
Hope this helps you out!

Related

Issue with BAM Continuation for BizTalk

I have developed a BizTalk Application. It receives a xml file and, after applying the business logic, it sends the file to another location using FILE adapter. I need to track the start and end time for both Receive Port and Send Port. I have created BAM activities and view and have created a tracking profile using Tracking Profile Editor. I have used Interchange ID as continuation ID token.
The problem is that in the BAM tracking, I am getting two rows, one for the receive port and second for the send port. The continuation between the receive and send port is not working.
The Continuation is not working most likely because InterchangeID is not naturally Promoted.
The small issue you have is that there is no naturally Promoted Property that can be used out of the box for this.
The simplest solution would be to create a custom Pipeline Component that Promotes InterchangeID (same property, just Promoted). Then your Tracking Profile should start working.
FYI, it this point, you don't really need BAM as it's pretty easy to query tracking directly using the same Promoted Property (which is what BAM is essentially doing using a slightly different path).
The interchange id will be present in the message context. Can you please confirm you mapped receive and send ports to the continuations in the tracking profile editor. Refer the article https://www.biztalk-server-tutorial.com/2013/02/08/how-to-enable-bam-continuation-between-receive-send-ports-using-tracking-profile-editor/ which shows the steps to add continuation correctly.

BizTalk 2013 Save a copy of received EDI file

I am trying to save copies of the EDI files I am receiving from an ftp server. I have tried using a send port to a file, but the parties will not resolve and it is using Fallback settings so I cannot set up proper validation, specifically allow leading and trailing zeros. Is there a better way to save a copy of the received EDI file.
Adding a Archiving Custom Pipeline component to the Receive Pipeline works for most scenarios.
The solution of Dijkgraaf (archiving pipeline component) makes a lot of sense, but just to provide you with other options:
The EDI files come in from somewhere. If this is a FILE or an FTP server for example, you could consider to script the archival of the file, by scripting the file move from the incoming folder to a folder where BizTalk is listening to. At that point it is very easy to make an extra copy of the original file before BizTalk is actually even seeing this. This can be done by a Scheduled Task or by BizTalk itself (PassThru pipelines).
Typically, it's not a bad design to separate your incoming folder from the folder where BizTalk will pick it up. This mostly depends on your own preferences. Do consider however that your BizTalk Server is often monitored and logged and your external scripts/scheduled tasks are not.
In that case I always tend to choose for the BizTalk 'PassThru' solution, since if this fails, you will be notified via the event log.
Before doing any custom work, take some to see if any of the built it BizTalk features can satisfy your requirement. There are two features specifically that address your situation:
EDI and AS2 Status Reporting - Stores incoming and outgoing EDI transactions and interchanges with their delivery status (997). The UI is built into BizTalk Administrator. Details here: EDI and AS2 Status Reporting
BizTalk Tracking: Can store any incoming or outgoing message. The search and retrieve UI is also part of BizTalk Administrator. Sample of how to use Tracking to archive messages: BizTalk Archiving, The BizTalk Way
Finally, you can consider a fully out-of-band solution by saving copies of the files before they even get to your BizTalk app.

BizTalk file Archive

I have an business requirement where each input file received on FTPS adapter at input location in BizTalk want to send back to client in original format at Archive location (FTPS).
Each input port have inbound map so original message converted and submitted to message box and when I read message on send port its already converted.
How do I get original message and send back to client.
Here as some options to look at
By using a File Archiving Pipeline component as the first thing in the pipeline and writing it to a folder and then having BizTalk pick it up from there using a pass-thru to send it on again.
Have a send port that also subscribed to the converted message that maps it back to the original message and sends it back. This will only be possible if you the original mapping is loss-less (don't lose any information).
Some of the FTP type adapters have the option to move the file after it is transferred rather than just deleting it, if it has use that.

Processing Empty Files in BizTalk 2010

I have a receive location in my BizTalk 2010 project, and sometimes that receive location will receive an empty file. The receive pipeline is PassThruReceive. We then have a Send Port that has a filter for that Receive Port Name. So all we are doing is moving the file from the receive location to the send location.
The issue that I'm running into is that in the event that we get an empty file in the receive location, my client wants the file to still be moved to the send port. I know that out of the box, the FILE adapter discards empty files and writes an event to the Event Log stating that it was deleted.
I have followed articles that show a custom FILE adapter accomplishing this task. I have had some success with this custom adapter. The file is picked up. Received by BizTalk and the Send Port successfully sends the file. However, even with this solution, I'm running into an issue in the receive side where the file is locked and cannot be deleted. I have followed various articles on this subject, and I get the same issue every time where the file is locked and can not be deleted.
My question is. Even though batchMessage.Message.BodyPart.Data.Close(); is being called, the stream is still locked. Is there any way for me to find where else BizTalk may be locking the file? Is there any other way of handling this?
One of the articles that I followed is located here: http://biztalkwithshashikant.blogspot.com/2011/04/processing-empty-files-in-biztalk.html
It seems to me that you are running into issues when running your custom FILE adapter multi-server. I bet you are running more than 1 server in the BizTalk Group?
I haven't done this myself, but I heard that getting an adapter to run smoothly multi-server is one of the hardest things to do in BizTalk. The trick is to find a way to be able to share the load between multiple instances of the same BizTalk host.
Do you still have the same problem when running the instance only on 1 server instead of 2?
in the custom pipeline component code method:
IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
You should return pInMsg, not set to null, and the .BodyPart stream positioned at the end. If pInMsg is null BizTalk will discard the message silently. You don't need to close it but you do need to move it to the end to let BizTalk know you read and processed it all.
A way around this is to use the FTP adapter instead to pick up the files, the FTP adapter does not discard empty files.
It is quite possible that to system creating the files, it is still a file location, but also accessible via FTP.

Outbound Map not being used

I have a receive port. It calls a stored procedure for transport, then the receive pipeline is just passthrureceive (I tried XMLReceive, but that caused many more issues). I have a send port that has the filter set so it picks up the type of the receive port. The send port has a map and send pipeline. The map maps the xml from the receive port to a flat file schema, and then sends it to it's location. THe send pipeline has a flat file assembler.
So the map never runs. I just get errors from the send pipeline saying it can't match the document. No it can't, because it wasn't mapped. I read that you need an XML Disassembler on the recieve pipeline of the receive location. I added that, and that just started destroying my messages. They just get turned into a blank message or just a " in the message. So the XML disassembler is clearly not working right. I'm not sure what to do at this point.
OK, I figured it out. I have to use the XML disassembler to make the map run. The reason it was erasing my messages is, well I don't know the reason, but when I set the schema to "elementFormDefault = Qualified", it worked. I'm not really sure what that did, as I really don't have a good understanding of the whole qualified message thing, but that was the problem for me.
There is a wizard in Visual Studio to help you create the schemas and bindings that you use to communicate with stored procedures. I guess you didn't use that? (Right click on the project, hit "Add", then "Add Generated Items", then "Consume Adapter Service")
I'm calling my stored procedure from an orchestration hooked to two way send/receive port. I'm using a custom WCF type port with XMLTransmit and XMLReceive for the pipelines. This seems to work fine. The caveat being it's always a bit fiddly getting WCF to work since there are so many options.
In order to map from one format to another on ports, you need to have MessageType promoted. In your case it can be accomplished by using XMLReceive on the receive pipeline.

Resources