public ActionResult <List <string> > Producer([FromBody] string mensagem) { var retorno = new List <string>(); // Definir o nome do Queue Manager e o nome Queue do MQ var nomeQueueManager = "nmQueueManager"; var nomeQueue = "nmQueue"; MQQueueManager queueManager = null; MQQueue queue = null; var openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING; var pmo = new MQPutMessageOptions(); try { queueManager = new MQQueueManager(nomeQueueManager, qMgrProp); //Console.WriteLine("MQTest01 successfully connected to " + qManager); queue = queueManager.AccessQueue(nomeQueue, openOptions); //Console.WriteLine("MQTest01 successfully opened " + outputQName); // Defina uma mensagem simples do MQ e escreva algum texto no formato UTF. var msg = new MQMessage(); msg.Format = MQC.MQFMT_STRING; msg.MessageType = MQC.MQMT_DATAGRAM; msg.MessageId = MQC.MQMI_NONE; msg.CorrelationId = MQC.MQCI_NONE; msg.WriteString(mensagem); // Colocar a mensagem na fila queue.Put(msg, pmo); retorno.Add("Mensagem: " + mensagem + " \n incluida com sucesso !\n" + queue.ToString()); } catch (MQException mqex) { Console.WriteLine("MQTest01 CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode); } catch (IOException ioex) { Console.WriteLine("MQTest01 ioex=" + ioex); } finally { try { if (queue != null) { queue.Close(); Console.WriteLine("MQTest01 closed: " + nomeQueue); } } catch (MQException mqex) { Console.WriteLine("MQTest01 CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode); } try { if (queueManager != null) { queueManager.Disconnect(); Console.WriteLine("MQTest01 disconnected from " + nomeQueueManager); } } catch (MQException mqex) { Console.WriteLine("MQTest01 CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode); } } return(retorno); }