A simple example of using Java Message Service (JMS) for sending and receiving messages to/from a queue.
The project contains two classes, each with its own main
method.
HelloWorldActiveMQ.java
demonstrates how to use JMS with ActiveMQ. Please refer to JMS_HelloWorld.pdf
or JMS_HelloWorld.docx
for more documentation on this example.
HelloWorldSQS.java
demonstrates how to use JMS with AWS SQS (Amazon Web Services - Simple Queue Service). The main
method first connects to SQS, then sends a text message, receives a text message, and finally closes the connection. To get the example running, two things have to be prepared:
- Add your AWS API credentials, the access key and the secret key, to
src/main/resources/aws.properties
(you may useaws.properties.example
as a template)
Note: Do not renameaws.properties.example
toaws.properties
but rather create a new file namedaws.properties
instead.
Otherwise, Git will no longer ignore the file, possibly resulting in your AWS credentials being committed and pushed and available to everyone. - Create a SQS queue, e.g. using the AWS console, and then adjust
private static final String queueName = "..."
accordingly (HelloWorldSQS.java, line 41
)