/// <summary> /// Initializes a new instance of the <see cref="T:RequestProcessorMSMQ"/> class. /// </summary> /// <param name="requestManager">The request manager.</param> public RequestProcessorMSMQ(RequestManager requestManager) : base(requestManager) { // Create the request manager client to receive messages from the queue requestManagerClient = new RequestManagerClientMSMQ(); // Set the queue name as specified via the custom configuration section requestManagerClient.QueueName = requestManager.CustomSettings["QueueName"]; }
/// <summary> /// This method will place the split message back on the queue /// </summary> /// <param name="requestMessage">The request message.</param> /// <returns></returns> private SubscriberStatusEnum Send(RequestMessage requestMessage) { RequestManagerClientMSMQ msmq = new RequestManagerClientMSMQ(); msmq.QueueName = ConfigurationManager.AppSettings["CommanderOutQueueName"]; RequestMessage newRequestMessage = null; if (hspgItems.Count > 0) { //convert the HSPG goods in records into a string string hspgMessage = String.Join(Environment.NewLine, hspgItems.ToArray()); //create a request message and set the body (Header, message and Footer) newRequestMessage = new RequestMessage(string.Concat(headerLine, hspgMessage, footerLine)); } if (tpcItems.Count > 0) { //convert TPC goods in records into a string string tpcMessage = String.Join(Environment.NewLine, tpcItems.ToArray()); //create a request message and set the body (Header, message and Footer) newRequestMessage = new RequestMessage(string.Concat(headerLine, tpcMessage, footerLine)); } if (newRequestMessage != null) { newRequestMessage.DestinationSystem = site; newRequestMessage.SourceSystem = requestMessage.DestinationSystem; newRequestMessage.Type = Integration.Connection.ConnectionTypeEnum.Commander.ToString(); // newRequestMessage.Name = fileNameToDownLoad;?? // newRequestMessage.Sequence = task.SequenceNumber; //send message msmq.Send(newRequestMessage); } return(SubscriberStatusEnum.Processed); }
private void Main_Load(object sender, EventArgs e) { requestMSMQ = new RequestManagerClientMSMQ(); }
/// <summary> /// This method will iterate through the collection CommanderSalesOrder objects supplied calling their GenerateCSV() methods. /// The return value from these method calls will be separated by an end of line character and outputted as a body to be routed to Commander by the Integration layer. /// </summary> /// <param name="salesOrders">The sales orders.</param> /// <param name="newLineCharacter">A string which represents the new line characters(s) to append to the end of each line.</param> /// <returns>Success</returns> public static bool GenerateSalesOrders(List <CommanderSalesOrder> salesOrders, string newLineCharacter) { List <string> generatedLines = new List <string>(); try { foreach (CommanderSalesOrder salesOrder in salesOrders) { generatedLines.Add(salesOrder.GenerateCSV()); } //filename? string messageBody = String.Join(newLineCharacter, generatedLines.ToArray()); //commander out queue string queueName = ""; #if DEBUG Logger.Write(new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( "SendMSMQMessageToDestination.", "Integration Trace", 0, 0, TraceEventType.Information, null, null)); #endif RequestManagerClientMSMQ requestManagerClient = new RequestManagerClientMSMQ(); requestManagerClient.QueueName = queueName; RequestMessage requestMessage = new RequestMessage(); //requestMessage.DestinationSystem = task.DestinationConnectionIdentifier; //requestMessage.SourceSystem = task.SourceConnectionIdentifier; //requestMessage.Type = task.SourceConnection.ConnectionType.ToString(); //requestMessage.Body = messageBody; //requestMessage.Name = fileNameToDownLoad; //requestMessage.Sequence = task.SequenceNumber; #if DEBUG Logger.Write(new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Format("About to send message to queue '{0}.", requestManagerClient.QueueName), "Integration Trace", 0, 0, TraceEventType.Information, null, null)); #endif requestManagerClient.Send(requestMessage); #if DEBUG Logger.Write(new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Format("Sent message to queue '{0}'. ", requestManagerClient.QueueName), "Integration Trace", 0, 0, TraceEventType.Information, null, null)); #endif } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, "Business Logic")) { throw; } } return(false); }