Sending message to AWS SQS from mirth using AWS java SDK
Pre-requisites:
- MirthConnect : 3.7.1
- AWS Set up
- Created SQS in AWS
- AWS Access Id and secret key(Required for authentication)
- AWS Java SDK
- aws-java-sdk-core-1.11.194 jar(Required same version as to avoid mirth version mismatch)
Here mainly I’m giving the code snippet to add your message to SQS queue so you can use it in your channel either is source/destination transformer based on your requirement.Also here I’m using a basic message for the queue you can have any type of message for the queue
var sqs = new //Provide your Access Id, secret key and region in the below code com.amazonaws.services.sqs.AmazonSQSClientBuilder.standard().withCredentials(new com.amazonaws.auth.AWSStaticCredentialsProvider(new com.amazonaws.auth.BasicAWSCredentials(Access Id, secret key))).withRegion(region).build(); var queue_url = sqs.getQueueUrl(QueueName).getQueueUrl(); logger.debug("queue: "+queue_url); var send_batch_request = new com.amazonaws.services.sqs.model.SendMessageBatchRequest() .withQueueUrl(queue_url) .withEntries( new com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry( "msg_1", "My First Queue") .withDelaySeconds(10));//Delay in seconds as you required sqs.sendMessageBatch(send_batch_request);
I hope the above code helps to your solution.Feel free to comment in below comment section for any more queries
I like the helpful info you provide on your articles. I’ll bookmark your weblog and check once more right here regularly. I am slightly certain I’ll learn many new stuff right here! Good luck for the following!
Hi Vibin,
I’m sending messages to SQS from Mirth using your code sinppet. However, I’m seeing the below error when I post my message. I use Mirth 3.6.1 and aws-java-sdk-core-1.11.194.jar. Could that be causing this? Any thoughts?
ERROR:
TypeError: [JavaPackage com.amazonaws.services.sqs.AmazonSQSClientBuilder.standard] is not a function, it is object.