-
1. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sfcoy Jul 15, 2013 8:47 AM (in response to sketcha)Do these annotated beans use @Resource to get references to the message destinations?
JBossAS tries to use these to order startup and shutdown correctly.
-
2. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sketcha Jul 15, 2013 9:13 AM (in response to sfcoy)Not directly. I am using the @Resource to get reference of message destination in a utility class which will be invoked from these beans
-
3. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sfcoy Jul 15, 2013 9:33 AM (in response to sketcha)If the utility class is injected (@EJB?) then the dependency graph should still work.
Is this how you're getting your utility class reference?
-
4. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sketcha Jul 16, 2013 7:06 AM (in response to sfcoy)Hi, Thanks for the answer. earlier i had wrongly mentioned that @Resource annotation But we are using Jndi Lookup to obtain message destination reference. This is how my Code snippet looks like.
My utility class
public class EventPublisher implements EventPublisherIf {
private static final String topicName = "topic/eventTopic";
private Context jndiContext;
private TopicConnectionFactory topicConnectionFactory;
private TopicConnection topicConnection;
private Topic topic;
private TopicPublisher topicPublisher;
private TopicSession topicSession = null;
private ObjectMessage objectMessage;
private static EventPublisherIf eventPublisher;
private boolean sessionActive = true;
public static synchronized EventPublisherIf getEventPublisher() {
if (eventPublisher == null) {
eventPublisher = new EventPublisher();
lookUpTopic();
}
return eventPublisher;
}
private void lookUpTopic() {
try {
jndiContext = new InitialContext();
topicConnectionFactory = (TopicConnectionFactory) jndiContext
.lookup("ConnectionFactory");
topic = (Topic) jndiContext.lookup(topicName);
} catch (NamingException e) {
log.error("Failed to lookup topic", e);
}
}
public void createTopicConnection() {
try{
try {
topicConnection = topicConnectionFactory.createTopicConnection("user","password");
} catch (JMSSecurityException e) {
topicConnection = topicConnectionFactory
.createTopicConnection();
}
topicConnection.setExceptionListener(new JmsExceptionHandler());
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
topicPublisher = topicSession.createPublisher(topic);
sessionActive = true;
} catch (JMSException e) {
sessionActive = false;
}
}
public synchronized void publishEvent(BaseEvent event) {
try {
if (!sessionActive) {
createTopicConnection();
}
if (sessionActive) {
objectMessage = topicSession.createObjectMessage(event);
topicPublisher.publish(objectMessage);
}
} catch (JMSException e) {
sessionActive = false;
}
}
}
and my bean code
@Stateless
@Remote(Processor.class)
public class ProcessorBean implements Processor{
@PostConstruct
public void initProcessor(){
EventPublisher.getEventPublisher().publishEvent(new BaseEvent("ProcessorInit");
}
@PostConstruct
public void stopProcessor(){
EventPublisher.getEventPublisher().publishEvent(new BaseEvent("ProcessorShutdown");
}
public void process(){
}
}
Kindly let me know if i need to change anything to make it work with dependency
-
5. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sfcoy Jul 16, 2013 7:52 AM (in response to sketcha)A short term cheat to begin might be to add
{code:java}@Resource(lookup="topic/eventTopic")
private Topic topic;{code}
to your ProcessorBean.
This should make your EJB dependent upon the topic even if it's unused.
In the medium term, convert your EventPublisher into another stateless session bean (using @Resource and getting rid of the JNDI lookups) and then inject it into ProcessorBean and any other clients.
-
6. Re: Jboss 7.2 Issue with hornetqueue JMS while shutting down the server
sketcha Aug 5, 2013 6:41 AM (in response to sfcoy)Thank Stephen.. It worked for me