in MQConsumer/Class1.cs [72:117]
public string producerHandler(ILambdaContext context)
{
string region = Environment.GetEnvironmentVariable("AWS_REGION");
string user = GetParamValueAsync("MQ-Username", region).Result;
string password = GetParamValueAsync("MQ-Password", region).Result;
string url1 = GetParamValueAsync("MQ-Broker1URI", region).Result;
string url2 = GetParamValueAsync("MQ-Broker2URI", region).Result;
string queueName = GetParamValueAsync("MQ-QueueName", region).Result;
LambdaLogger.Log("queueName : " + queueName);
LambdaLogger.Log("user : " + user);
LambdaLogger.Log("password : " + password);
LambdaLogger.Log("url : " + url1); ;
LambdaLogger.Log("queueName : " + queueName);
Uri connecturi = new Uri("activemq:" + url1);
IConnectionFactory factory = new NMSConnectionFactory(connecturi);
LambdaLogger.Log("Connected : " + connecturi.ToString());
using (IConnection connection = factory.CreateConnection(user, password))
{
connection.Start();
IDestination destination;
using (ISession session = connection.CreateSession())
{
destination = session.GetQueue(queueName);
using (IMessageProducer producer = session.CreateProducer(destination))
{
IMessage msg = producer.CreateTextMessage("Test Message at " + DateTime.Now.ToString());
producer.Send(msg);
return msg.ToString();
}
}
}
}