Navigation Menu

Skip to content

Commit

Permalink
stop listening for JMS messages when a test is over
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Dec 9, 2013
1 parent a618ce9 commit 24169f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Expand Up @@ -90,6 +90,9 @@ public void acquireConnection() throws JMSException {

@After
public void releaseConnection() throws JMSException {
// ignore any remaining or queued messages
consumer.setMessageListener(new NoopListener());
// and shut the listening machinery down
logger.debug(this.getClass().getName() + " releasing JMS connection.");
consumer.close();
session.close();
Expand Down Expand Up @@ -260,10 +263,10 @@ public void testDatastreamTerm() throws RepositoryException,

@Override
public void onMessage(final Message message) {
logger.debug("Received JMS message: " + message.toString());

final TextMessage tMessage = (TextMessage) message;
try {
logger.debug("Received JMS message: " + tMessage.getText());
if (LegacyMethod.canParse(message)) {
final LegacyMethod legacy = new LegacyMethod(tMessage.getText());
final Entry entry = legacy.getEntry();
Expand Down Expand Up @@ -292,5 +295,4 @@ private void waitForEntry(final int size) throws InterruptedException {
}
}
}

}
Expand Up @@ -191,6 +191,9 @@ public void acquireConnection() throws JMSException {

@After
public void releaseConnection() throws JMSException {
// ignore any remaining or queued messages
consumer.setMessageListener(new NoopListener());
// and shut the listening machinery down
LOGGER.debug(this.getClass().getName() + " releasing JMS connection.");
consumer.close();
session.close();
Expand Down
@@ -0,0 +1,28 @@
/**
* Copyright 2013 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.integration.jms.observer;

import javax.jms.Message;
import javax.jms.MessageListener;

class NoopListener implements MessageListener {

@Override
public void onMessage(Message arg0) {

}

}

0 comments on commit 24169f2

Please sign in to comment.