/// <summary> /// Creates IBaseMessage object from string /// </summary> /// <param name="mf">Reference to BizTalk message factory object</param> /// <param name="url">Address of receive location where this message will be submitted</param> /// <param name="data">Payload of the message</param> /// <returns>BizTalk message object</returns> public static IBaseMessage CreateMessage(IBaseMessageFactory mf, string url, string data) { IBaseMessagePart part = null; IBaseMessageContext ctx = null; IBaseMessage msg = null; SystemMessageContext smc = null; // Write the data to a new stream... StreamWriter sw = new StreamWriter(new MemoryStream()); sw.Write(data); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin.Begin); // Create a new message msg = mf.CreateMessage(); part = mf.CreateMessagePart(); part.Data = sw.BaseStream; ctx = msg.Context; msg.AddPart("body", part, true); // Set the system context properties smc = new SystemMessageContext(ctx); if ( null != url ) smc.InboundTransportLocation = url; return msg; }
public void Resubmit(IBaseMessage msg, bool preserveRetryCount, object userData) { SystemMessageContext context = new SystemMessageContext(msg.Context); if (preserveRetryCount) { UpdateProperty[] updates = new UpdateProperty[1]; updates[0] = new UpdateProperty(); updates[0].Name = retryCountProp.Name.Name; updates[0].NameSpace = retryCountProp.Name.Namespace; updates[0].Value = context.RetryCount++; context.UpdateProperties(updates); // If preserveRetryCount is true, ignore RetryInterval // Request the redelivery immediately!! base.Resubmit(msg, DateTime.Now, userData); } else { // This is retry in case of error/failure (i.e. normal retry) if (context.RetryCount > 0) { DateTime retryAt = DateTime.Now.AddMinutes(context.RetryInterval); base.Resubmit(msg, retryAt, userData); } else { base.MoveToNextTransport(msg, userData); } } }
/// <summary> /// Creates IBaseMessage object from stream /// </summary> /// <param name="mf">Reference to the BizTalk message factory</param> /// <param name="url">Address of receive location where this message will be submitted to</param> /// <param name="charset">Charset of the date</param> /// <param name="data">Message payload</param> /// <returns>BizTalk message object</returns> public static IBaseMessage CreateMessage(IBaseMessageFactory mf, string url, string charset, Stream data) { IBaseMessagePart part = null; IBaseMessageContext ctx = null; IBaseMessage msg = null; SystemMessageContext smc = null; // Create a new message msg = mf.CreateMessage(); part = mf.CreateMessagePart(); part.Data = data; part.Charset = charset; ctx = msg.Context; msg.AddPart("body", part, true); // Set the system context properties smc = new SystemMessageContext(ctx); if ( null != url ) smc.InboundTransportLocation = url; return msg; }
private void HandleException(AdapterException e, Batch batch, IBaseMessage message) { message.SetErrorInfo(e); SystemMessageContext context = new SystemMessageContext(message.Context); if (context.RetryCount > 0) { DateTime now = DateTime.Now; int retryInterval = context.RetryInterval; DateTime retryTime = now.AddMinutes(retryInterval); batch.Resubmit(message, retryTime); } else { batch.MoveToNextTransport(message); } }
// Endpoint management is the responsibility of the transmitter protected virtual EndpointParameters CreateEndpointParameters(IBaseMessage message) { SystemMessageContext context = new SystemMessageContext(message.Context); return new DefaultEndpointParameters(context.OutboundTransportLocation); }
/// <summary> /// Initialize the adapter by taken the address of receive location from message context /// </summary> /// <param name="tp">Transport proxy object reference</param> /// <param name="message">BizTalk message object reference</param> /// <param name="callBack">Reference to the configuration callback interface</param> private void InternalInitialize(IBTTransportProxy tp, IBaseMessage message, IBTTransportConfig callBack) { IBaseMessageContext ctx; ctx = message.Context; SystemMessageContext smc = new SystemMessageContext(ctx); string url = smc.InboundTransportLocation; InternalInitialize(tp, url, callBack); }
/// <summary> /// Transmit a message handed down by the EPM /// </summary> /// <param name="msg">Message to send</param> /// <returns>True if the message was sent successfuly</returns> public bool TransmitMessage(IBaseMessage msg) { _terminate.Enter(); try { bool logMessages = Convert.ToBoolean( GetAdapterConfigValue(msg.Context, "logMessages") ); if ( logMessages ) { SystemMessageContext ctxt = new SystemMessageContext(msg.Context); LogHelper.LogMessage(msg.MessageID, ctxt.InterchangeID); } // // discard the message // return true; } finally { _terminate.Leave(); } }
/// <summary> /// Creates an array of IBaseMessage objects from array of strings /// </summary> /// <param name="mf">Reference to BizTalk message factory object</param> /// <param name="url">Address of receive location where this message will be submitted to</param> /// <param name="data">Payloads for each message</param> /// <returns>Array of BizTalk message objects</returns> public static IBaseMessage[] CreateMessages(IBaseMessageFactory mf, string url, string[] data) { IBaseMessagePart part = null; IBaseMessageContext ctx = null; IBaseMessage[] msgs = null; SystemMessageContext smc = null; msgs = new IBaseMessage[data.Length]; for ( int c = 0; c < data.Length; c++ ) { // Write the data to a new stream... StreamWriter sw = new StreamWriter(new MemoryStream()); sw.Write(data[c]); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin.Begin); // Create a new message msgs[c] = mf.CreateMessage(); part = mf.CreateMessagePart(); part.Data = sw.BaseStream; ctx = msgs[c].Context; msgs[c].AddPart("body", part, true); // Set the system context properties smc = new SystemMessageContext(ctx); if ( null != url ) smc.InboundTransportLocation = url; } return msgs; }
/// <summary> /// Creates IBaseMessage objects from array of streams /// </summary> /// <param name="mf">Reference to BizTalk message factory object</param> /// <param name="url">Address of receive location where this message will be submitted to</param> /// <param name="data">Payloads for each message</param> /// <returns>Array of BizTalk message objects</returns> public static IBaseMessage[] CreateMessages(IBaseMessageFactory mf, string url, Stream[] data) { IBaseMessagePart part = null; IBaseMessageContext ctx = null; IBaseMessage[] msgs = null; SystemMessageContext smc = null; msgs = new IBaseMessage[data.Length]; for ( int c = 0; c < data.Length; c++ ) { // Create a new message msgs[c] = mf.CreateMessage(); part = mf.CreateMessagePart(); part.Data = data[c]; ctx = msgs[c].Context; msgs[c].AddPart("body", part, true); // Set the system context properties smc = new SystemMessageContext(ctx); if ( null != url ) smc.InboundTransportLocation = url; } return msgs; }
// No action required when delete fails! protected override void ResubmitSuccess(IBaseMessage message, Int32 hrStatus, object userData) { if (this.batchFailed) { SystemMessageContext context = new SystemMessageContext(message.Context); DateTime dt = DateTime.Now.AddMinutes(context.RetryInterval); this.batch.Resubmit(message, dt); } }