]
Antonio Goncalves updated FORGE-2416:
-------------------------------------
Labels: Starter (was: )
Being able to send JMS messages
-------------------------------
Key: FORGE-2416
URL:
https://issues.jboss.org/browse/FORGE-2416
Project: Forge
Issue Type: Sub-task
Components: Java EE
Affects Versions: 2.17.0.Final
Reporter: Antonio Goncalves
Labels: Starter
Fix For: 2.x Future
It would be good to have a command to quickly add code to allow sending JMS messages. The
following command would create the needed code using a message of type String :
{code}
jms-add-send-message-method --named sendMessage --destinationType QUEUE --destinationName
myQueue
{code}
This would inject the {{javax.jms.JMSContext}} and add a method to send JMS message :
{code}
@Inject
JMSContext context;
@Resource(mappedName = "myQueue")
Queue queue;
public void sendMessage(String message) {
context.createProducer().send(queue, message);
}
{code}
To customize the message type, we just use the {{type}} parameter :
{code}
jms-add-send-message-method --named sendMessage --type MyBean --destinationType QUEUE
--destinationName myQueue
{code}
We will get the following code :
{code}
@Inject
JMSContext context;
@Resource(mappedName = "myQueue")
Queue queue;
public void sendMessage(MyBean message) {
context.createProducer().send(queue, message);
}
{code}