|
Home > Archive > BizTalk Server General > May 2004 > Errorhandling in Adapter
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Errorhandling in Adapter
|
|
|
| Hi,
I've build my own Adapter (based on HttpAdapter). The Adapter works so far but ErrorHandling leads to some problems. Within the implementation of "IThreadPoolWorkItem" in method "ProcessWorkItem" resp. in "OneWaySend" I implemented sending of a message. I
f sending fails I want to see the error message in Eventlog or better in HAT. I catched the error while sending the message and used the msg.Message.SetErrorInfo(ex) and even this.transportProxy.SetErrorInfo(ex). None of them works. The message is suspend
ed (resumable), not resubmitted and the only "Errormessages" I've got are:
[Eventlog]
The Messaging Engine has suspended "1" message(s) due to outbound processing errors. Please use Health and Activity Tracking to determine the cause of this failure.
[HAT]
A failure was encountered while transmitting the message
Whats wrong?
For better understanding here the sourcecode (cutted - the SetErrorInfo lines are marked):
namespace ODAdapter
{
internal class ODAdapterWorkItem : IThreadpoolWorkItem
{
private TransmitterMessage solicitMsg = null;
private IBTTransportProxy transportProxy = null;
private AsyncTransmitter asyncTransmitter = null;
private const int IIS_LARGE_DATA_THRESHHOLD = 49152; // 48K
public ODAdapterWorkItem (IBTTransportProxy transportProxy, AsyncTransmitter asyncTransmitter)
{
this.transportProxy = transportProxy;
this.asyncTransmitter = asyncTransmitter;
}
public TransmitterMessage SolicitMessage
{
get { return this.solicitMsg; }
set { this.solicitMsg = value; }
}
public void ProcessWorkItem ()
{
try
{
StandardTransmitBatchHandler btsBatch = new StandardTransmitBatchHandler(transportPr
oxy, null);
IBaseMessage responseMsg = null;
if ( this.solicitMsg.PortIsTwoWay )
{
//it's a oneway port
}
else
{
if ( OneWaySend(this.solicitMsg) )
btsBatch.DeleteMessage(this.solicitMsg.Message, null);
else
btsBatch.Resubmit(this.solicitMsg.Message, null);
}
try
{
btsBatch.BeginDone(null, new AsyncCallback(BatchComplete), (object)responseMsg);
}
catch(COMException e)
{
Trace.WriteLine(string.Format("Exception caught in ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter: Error" );
if ( e.ErrorCode != BTTransportProxy.BTS_E_MESSAGING_SHUTTING_DOWN )
{
this.transportProxy.SetErrorInfo(e);
throw e;
}
}
}
catch(Exception e)
{
Trace.WriteLine(string.Format("Exception caught in ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter: Error" );
this.transportProxy.SetErrorInfo(e);
throw new ODAdapterException(ODAdapterException.UnhandledTransmit_Error, e);
}
finally
{
this.asyncTransmitter.Leave();
}
}
public void BatchComplete(IAsyncResult ar)
{
IBaseMessage responseMsg = (IBaseMessage)ar.AsyncState;
if ( null != responseMsg )
responseMsg.BodyPart.GetOriginalDataStream().Close();
}
private bool OneWaySend(TransmitterMessage msg)
{
bool result = false;
try
{
//send message here...
//raises an error
result = true;
}
catch (Exception ex)
{
---> this.transportProxy.SetErrorInfo(ex);
---> msg.Message.SetErrorInfo(ex);
string errorText = "Problem sending message one way to AD MQ! Details: " + ex.ToString();
Trace.WriteLine(string.Format("Exception caught in ODAdapterWorkItem.ProcessWorkItem(): {0}", errorText), "OD Transmit Adapter: Error" );
}
return result;
}
}
}
| |
| Christof 2004-05-30, 10:46 am |
| Do you use transactions please?
Did everything roll back perhaps?
Kind regards,
Christof
"Dirk" <anonymous@discussions.microsoft.com> wrote in message
news:971F4073-1BE9-4882-9023-B599A6689085@microsoft.com...
> Hi,
>
> I've build my own Adapter (based on HttpAdapter). The Adapter works so far
but ErrorHandling leads to some problems. Within the implementation of
"IThreadPoolWorkItem" in method "ProcessWorkItem" resp. in "OneWaySend" I
implemented sending of a message. If sending fails I want to see the error
message in Eventlog or better in HAT. I catched the error while sending the
message and used the msg.Message.SetErrorInfo(ex) and even
this.transportProxy.SetErrorInfo(ex). None of them works. The message is
suspended (resumable), not resubmitted and the only "Errormessages" I've got
are:
>
> [Eventlog]
> The Messaging Engine has suspended "1" message(s) due to outbound
processing errors. Please use Health and Activity Tracking to determine the
cause of this failure.
>
> [HAT]
> A failure was encountered while transmitting the message
>
> Whats wrong?
>
> For better understanding here the sourcecode (cutted - the SetErrorInfo
lines are marked):
>
> namespace ODAdapter
> {
> internal class ODAdapterWorkItem : IThreadpoolWorkItem
> {
> private TransmitterMessage solicitMsg = null;
> private IBTTransportProxy transportProxy = null;
> private AsyncTransmitter asyncTransmitter = null;
> private const int IIS_LARGE_DATA_THRESHHOLD = 49152; // 48K
>
> public ODAdapterWorkItem (IBTTransportProxy transportProxy,
AsyncTransmitter asyncTransmitter)
> {
> this.transportProxy = transportProxy;
> this.asyncTransmitter = asyncTransmitter;
> }
>
> public TransmitterMessage SolicitMessage
> {
> get { return this.solicitMsg; }
> set { this.solicitMsg = value; }
> }
>
> public void ProcessWorkItem ()
> {
> try
> {
> StandardTransmitBatchHandler btsBatch = new
StandardTransmitBatchHandler(transportPr
oxy, null);
> IBaseMessage responseMsg = null;
>
> if ( this.solicitMsg.PortIsTwoWay )
> {
> //it's a oneway port
> }
> else
> {
> if ( OneWaySend(this.solicitMsg) )
> btsBatch.DeleteMessage(this.solicitMsg.Message, null);
> else
> btsBatch.Resubmit(this.solicitMsg.Message, null);
> }
>
> try
> {
> btsBatch.BeginDone(null, new AsyncCallback(BatchComplete),
(object)responseMsg);
> }
> catch(COMException e)
> {
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter:
Error" );
>
> if ( e.ErrorCode != BTTransportProxy.BTS_E_MESSAGING_SHUTTING_DOWN )
> {
> this.transportProxy.SetErrorInfo(e);
> throw e;
> }
> }
> }
> catch(Exception e)
> {
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter:
Error" );
> this.transportProxy.SetErrorInfo(e);
>
> throw new ODAdapterException(ODAdapterException.UnhandledTransmit_Error,
e);
> }
> finally
> {
> this.asyncTransmitter.Leave();
> }
> }
>
> public void BatchComplete(IAsyncResult ar)
> {
> IBaseMessage responseMsg = (IBaseMessage)ar.AsyncState;
> if ( null != responseMsg )
> responseMsg.BodyPart.GetOriginalDataStream().Close();
> }
>
> private bool OneWaySend(TransmitterMessage msg)
> {
> bool result = false;
>
> try
> {
> //send message here...
> //raises an error
>
> result = true;
> }
> catch (Exception ex)
> {
>
> ---> this.transportProxy.SetErrorInfo(ex);
> ---> msg.Message.SetErrorInfo(ex);
>
> string errorText = "Problem sending message one way to AD MQ! Details: " +
ex.ToString();
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", errorText), "OD Transmit Adapter:
Error" );
> }
>
> return result;
> }
>
> }
> }
>
>
| |
|
| No - no transactions!
But after restart BizTalk Service BizTalk Group - Service everything works magically... I can see errors in Messageflow which was not available before.
Nevertheless - thanx for support!
Dirk
----- Christof wrote: -----
Do you use transactions please?
Did everything roll back perhaps?
Kind regards,
Christof
"Dirk" <anonymous@discussions.microsoft.com> wrote in message
news:971F4073-1BE9-4882-9023-B599A6689085@microsoft.com...
> Hi,
but ErrorHandling leads to some problems. Within the implementation of
"IThreadPoolWorkItem" in method "ProcessWorkItem" resp. in "OneWaySend" I
implemented sending of a message. If sending fails I want to see the error
message in Eventlog or better in HAT. I catched the error while sending the
message and used the msg.Message.SetErrorInfo(ex) and even
this.transportProxy.SetErrorInfo(ex). None of them works. The message is
suspended (resumable), not resubmitted and the only "Errormessages" I've got
are:[vbcol=seagreen]
> The Messaging Engine has suspended "1" message(s) due to outbound
processing errors. Please use Health and Activity Tracking to determine the
cause of this failure.
> A failure was encountered while transmitting the message
lines are marked):[vbcol=seagreen]
> {
> internal class ODAdapterWorkItem : IThreadpoolWorkItem
> {
> private TransmitterMessage solicitMsg = null;
> private IBTTransportProxy transportProxy = null;
> private AsyncTransmitter asyncTransmitter = null;
> private const int IIS_LARGE_DATA_THRESHHOLD = 49152; // 48K
AsyncTransmitter asyncTransmitter)[vbcol=seagreen]
> {
> this.transportProxy = transportProxy;
> this.asyncTransmitter = asyncTransmitter;
> }
> {
> get { return this.solicitMsg; }
> set { this.solicitMsg = value; }
> }
> {
> try
> {
> StandardTransmitBatchHandler btsBatch = new
StandardTransmitBatchHandler(transportPr
oxy, null);
> IBaseMessage responseMsg = null;
> {
> //it's a oneway port
> }
> else
> {
> if ( OneWaySend(this.solicitMsg) )
> btsBatch.DeleteMessage(this.solicitMsg.Message, null);
> else
> btsBatch.Resubmit(this.solicitMsg.Message, null);
> }
> {
> btsBatch.BeginDone(null, new AsyncCallback(BatchComplete),
(object)responseMsg);
> }
> catch(COMException e)
> {
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter:
Error" );
> {
> this.transportProxy.SetErrorInfo(e);
> throw e;
> }
> }
> }
> catch(Exception e)
> {
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", e), "OD Transmit Adapter:
Error" );
> this.transportProxy.SetErrorInfo(e);
e);[vbcol=seagreen]
> }
> finally
> {
> this.asyncTransmitter.Leave();
> }
> }
> {
> IBaseMessage responseMsg = (IBaseMessage)ar.AsyncState;
> if ( null != responseMsg )
> responseMsg.BodyPart.GetOriginalDataStream().Close();
> }
> {
> bool result = false;
> {
> //send message here...
> //raises an error
> }
> catch (Exception ex)
> {
> ---> msg.Message.SetErrorInfo(ex);
ex.ToString();[vbcol=seagreen]
> Trace.WriteLine(string.Format("Exception caught in
ODAdapterWorkItem.ProcessWorkItem(): {0}", errorText), "OD Transmit Adapter:
Error" );[vbcol=seagreen]
> }
> }
> }
|
|
|
|
|