From c9a3202bc3b526bdf65f239dad68f555d7b83df1 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 8 Jun 2015 15:51:44 +0100 Subject: [PATCH 01/52] https://issues.jboss.org/browse/ENTMQ-780 pauses the delivery of messages to the activemq session when a rollback is happening until the message has been redelivered. patch applied with thanks to Tamas Cserveny --- .../org/apache/activemq/ActiveMQSession.java | 23 +++++++++++++++++-- .../activemq/ActiveMQSessionExecutor.java | 11 +++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java index 1d2ae836fb..2e0f6468fa 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java @@ -717,7 +717,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta if (!closed) { try { - executor.stop(); + executor.close(); for (Iterator iter = consumers.iterator(); iter.hasNext();) { ActiveMQMessageConsumer consumer = iter.next(); @@ -978,11 +978,24 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta for (int i = 0; i < redeliveryCounter; i++) { redeliveryDelay = redeliveryPolicy.getNextRedeliveryDelay(redeliveryDelay); } + + if ( connection.isNonBlockingRedelivery() == false) { + LOG.debug("Blocking session until re-delivery..."); + executor.stop(); + } + connection.getScheduler().executeAfterDelay(new Runnable() { @Override public void run() { - ((ActiveMQDispatcher)md.getConsumer()).dispatch(md); + + if (connection.isNonBlockingRedelivery()) { + ((ActiveMQDispatcher)md.getConsumer()).dispatch(md); + } else { + LOG.debug("Session released, issuing re-delivery..."); + executor.executeFirst(md); + executor.start(); + } } }, redeliveryDelay); } @@ -1016,6 +1029,12 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta if (deliveryListener != null) { deliveryListener.afterDelivery(this, message); } + + try { + executor.waitForQueueRestart(); + } catch (InterruptedException ex) { + connection.onClientInternalException(ex); + } } } diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java index caa1ca9884..357815561c 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java @@ -207,4 +207,15 @@ public class ActiveMQSessionExecutor implements Task { List getUnconsumedMessages() { return messageQueue.removeAll(); } + + void waitForQueueRestart() throws InterruptedException { + synchronized (messageQueue.getMutex()) { + while (messageQueue.isRunning() == false) { + if (messageQueue.isClosed()) { + break; + } + messageQueue.getMutex().wait(); + } + } + } } From 67c28b1c6801562187cfa41c2846133e3aac139f Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 8 Jun 2015 15:53:48 +0100 Subject: [PATCH 02/52] https://issues.jboss.org/browse/ENTMQ-780 A couple of tests to add to the patch provided --- .../apache/activemq/RedeliveryPolicyTest.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java index 659e9827e3..ac81a1f410 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -615,6 +617,101 @@ public class RedeliveryPolicyTest extends JmsTestSupport { } + public void testRedeliveryRollbackWithDelayBlocking() throws Exception + { + redeliveryRollbackWithDelay(true); + } + + public void testRedeliveryRollbackWithDelayNonBlocking() throws Exception + { + redeliveryRollbackWithDelay(false); + } + + public void redeliveryRollbackWithDelay(final boolean blockingRedelivery) throws Exception { + + connection.start(); + Session sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + ActiveMQQueue destination = new ActiveMQQueue("TEST"); + MessageProducer producer = sendSession.createProducer(destination); + producer.send(sendSession.createTextMessage("1st")); + producer.send(sendSession.createTextMessage("2nd")); + + + connection = (ActiveMQConnection)factory.createConnection(userName, password); + connections.add(connection); + + RedeliveryPolicy policy = connection.getRedeliveryPolicy(); + policy.setInitialRedeliveryDelay(2000); + policy.setUseExponentialBackOff(false); + connection.setNonBlockingRedelivery(blockingRedelivery); + connection.start(); + final CountDownLatch done = new CountDownLatch(3); + + final ActiveMQSession session = (ActiveMQSession) connection.createSession(true, Session.SESSION_TRANSACTED); + final List list = new ArrayList<>(); + session.setMessageListener(new MessageListener() { + @Override + public void onMessage(Message message) { + try { + ActiveMQTextMessage m = (ActiveMQTextMessage) message; + LOG.info("Got: " + ((ActiveMQTextMessage) message).getMessageId() + ", seq:" + ((ActiveMQTextMessage) message).getMessageId().getBrokerSequenceId()); + list.add(((ActiveMQTextMessage) message).getText()); + if (done.getCount() == 3) + { + session.rollback(); + } + done.countDown(); + + } catch (Exception ignored) { + ignored.printStackTrace(); + } + } + }); + + connection.createConnectionConsumer( + destination, + null, + new ServerSessionPool() { + @Override + public ServerSession getServerSession() throws JMSException { + return new ServerSession() { + @Override + public Session getSession() throws JMSException { + return session; + } + + @Override + public void start() throws JMSException { + } + }; + } + }, + 100, + false); + + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + session.run(); + return done.await(10, TimeUnit.MILLISECONDS); + } + }, 5000); + + connection.close(); + connections.remove(connection); + + assertEquals(list.size(), 3); + if (blockingRedelivery) { + assertEquals("1st", list.get(0)); + assertEquals("2nd", list.get(1)); + assertEquals("1st", list.get(2)); + } else { + assertEquals("1st", list.get(0)); + assertEquals("1st", list.get(1)); + assertEquals("2nd", list.get(2)); + } + } + public void testInitialRedeliveryDelayZero() throws Exception { // Receive a message with the JMS API From eaf5c12151552e01c7de31bdcc8b96d8cbd3a1c6 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Mon, 8 Jun 2015 14:11:04 -0400 Subject: [PATCH 03/52] Add test to assert that preconditions are met before moving on to the rest of the checks. --- .../vm/VMTransportThreadSafeTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java index 8534f8908a..c5c4706ca5 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java @@ -523,18 +523,32 @@ public class VMTransportThreadSafeTest { @Override public void run() { try { - Thread.sleep(100); + Thread.sleep(200); } catch (InterruptedException e) { } ((GatedVMTestTransportListener) remote.getTransportListener()).gate.countDown(); } }); + + assertTrue(Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return remoteReceived.size() == 1; + } + })); + gateman.start(); remote.stop(); local.stop(); - assertEquals(1, remoteReceived.size()); + assertTrue(Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return remoteReceived.size() == 1; + } + })); + assertMessageAreOrdered(remoteReceived); } From 886e2d4d97555e2f10276616389a5d1f915bad18 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Fri, 1 May 2015 19:02:18 +0000 Subject: [PATCH 04/52] Adding a configuration option to PolicyEntry to enable setting the maximum number of created destinations by policy on the broker. This resolves https://issues.apache.org/jira/browse/AMQ-5751 --- .../broker/region/AbstractRegion.java | 82 +++++- .../broker/region/RegionStatistics.java | 89 ++++++ .../broker/region/policy/PolicyEntry.java | 17 ++ .../policy/MaxDestinationsPolicyTest.java | 271 ++++++++++++++++++ 4 files changed, 457 insertions(+), 2 deletions(-) create mode 100644 activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MaxDestinationsPolicyTest.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java index 4f487bfe45..ab47ea4e30 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java @@ -25,7 +25,10 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; +import javax.jms.IllegalStateException; import javax.jms.JMSException; + +import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConsumerBrokerExchange; import org.apache.activemq.DestinationDoesNotExistException; @@ -64,6 +67,7 @@ public abstract class AbstractRegion implements Region { protected final SystemUsage usageManager; protected final DestinationFactory destinationFactory; protected final DestinationStatistics destinationStatistics; + protected final RegionStatistics regionStatistics = new RegionStatistics(); protected final RegionBroker broker; protected boolean autoCreateDestinations = true; protected final TaskRunnerFactory taskRunnerFactory; @@ -120,7 +124,16 @@ public abstract class AbstractRegion implements Region { } finally { destinationsLock.readLock().unlock(); } - destinations.clear(); + + destinationsLock.writeLock().lock(); + try { + destinations.clear(); + regionStatistics.getAdvisoryDestinations().reset(); + regionStatistics.getDestinations().reset(); + regionStatistics.getAllDestinations().reset(); + } finally { + destinationsLock.writeLock().unlock(); + } } public Destination addDestination(ConnectionContext context, ActiveMQDestination destination, @@ -131,6 +144,10 @@ public abstract class AbstractRegion implements Region { Destination dest = destinations.get(destination); if (dest == null) { if (destination.isTemporary() == false || createIfTemporary) { + // Limit the number of destinations that can be created if + // maxDestinations has been set on a policy + validateMaxDestinations(destination); + LOG.debug("{} adding destination: {}", broker.getBrokerName(), destination); dest = createDestination(context, destination); // intercept if there is a valid interceptor defined @@ -140,6 +157,7 @@ public abstract class AbstractRegion implements Region { } dest.start(); destinations.put(destination, dest); + updateRegionDestCounts(destination, 1); destinationMap.put(destination, dest); addSubscriptionsForDestination(context, dest); } @@ -157,6 +175,61 @@ public abstract class AbstractRegion implements Region { return subscriptions; } + + /** + * Updates the counts in RegionStatistics based on whether or not the destination + * is an Advisory Destination or not + * + * @param destination the destination being used to determine which counters to update + * @param count the count to add to the counters + */ + protected void updateRegionDestCounts(ActiveMQDestination destination, int count) { + if (destination != null) { + if (AdvisorySupport.isAdvisoryTopic(destination)) { + regionStatistics.getAdvisoryDestinations().add(count); + } else { + regionStatistics.getDestinations().add(count); + } + regionStatistics.getAllDestinations().add(count); + } + } + + /** + * This method checks whether or not the destination can be created based on + * {@link PolicyEntry#getMaxDestinations}, if it has been set. Advisory + * topics are ignored. + * + * @param destination + * @throws Exception + */ + protected void validateMaxDestinations(ActiveMQDestination destination) + throws Exception { + if (broker.getDestinationPolicy() != null) { + PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination); + // Make sure the destination is not an advisory topic + if (entry != null && entry.getMaxDestinations() >= 0 + && !AdvisorySupport.isAdvisoryTopic(destination)) { + // If there is an entry for this destination, look up the set of + // destinations associated with this policy + // If a destination isn't specified, then just count up + // non-advisory destinations (ie count all destinations) + int destinationSize = (int) (entry.getDestination() != null ? + destinationMap.get(entry.getDestination()).size() : regionStatistics.getDestinations().getCount()); + if (destinationSize >= entry.getMaxDestinations()) { + if (entry.getDestination() != null) { + throw new IllegalStateException( + "The maxmimum number of destinations allowed ("+ entry.getMaxDestinations() + + ") for the policy " + entry.getDestination() + " has already been reached."); + // No destination has been set (default policy) + } else { + throw new IllegalStateException("The maxmimum number of destinations allowed (" + + entry.getMaxDestinations() + ") has already been reached."); + } + } + } + } + } + protected List addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception { @@ -210,6 +283,8 @@ public abstract class AbstractRegion implements Region { try { Destination dest = destinations.remove(destination); if (dest != null) { + updateRegionDestCounts(destination, -1); + // timeout<0 or we timed out, we now force any remaining // subscriptions to un-subscribe. for (Iterator iter = subscriptions.values().iterator(); iter.hasNext();) { @@ -620,7 +695,10 @@ public abstract class AbstractRegion implements Region { destination = destinationInterceptor.intercept(destination); } getDestinationMap().put(key, destination); - destinations.put(key, destination); + Destination prev = destinations.put(key, destination); + if (prev == null) { + updateRegionDestCounts(key, 1); + } } } finally { destinationsLock.writeLock().unlock(); diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java new file mode 100644 index 0000000000..d39a4f1214 --- /dev/null +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.broker.region; + +import org.apache.activemq.management.CountStatisticImpl; +import org.apache.activemq.management.StatsImpl; + +/** + * The J2EE Statistics for the Connection. + * + * + */ +public class RegionStatistics extends StatsImpl { + + private CountStatisticImpl advisoryDestinations; + private CountStatisticImpl destinations; + private CountStatisticImpl allDestinations; + + public RegionStatistics() { + this(true); + } + + public RegionStatistics(boolean enabled) { + + advisoryDestinations = new CountStatisticImpl("advisoryTopics", "The number of advisory destinations in the region"); + destinations = new CountStatisticImpl("destinations", "The number of regular (non-adivsory) destinations in the region"); + allDestinations = new CountStatisticImpl("allDestinations", "The total number of destinations, including advisory destinations, in the region"); + + addStatistic("advisoryDestinations", advisoryDestinations); + addStatistic("destinations", destinations); + addStatistic("allDestinations", allDestinations); + + this.setEnabled(enabled); + } + + public CountStatisticImpl getAdvisoryDestinations() { + return advisoryDestinations; + } + + public CountStatisticImpl getDestinations() { + return destinations; + } + + public CountStatisticImpl getAllDestinations() { + return allDestinations; + } + + public void reset() { + super.reset(); + advisoryDestinations.reset(); + destinations.reset(); + allDestinations.reset(); + } + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + advisoryDestinations.setEnabled(enabled); + destinations.setEnabled(enabled); + allDestinations.setEnabled(enabled); + } + + public void setParent(RegionStatistics parent) { + if (parent != null) { + advisoryDestinations.setParent(parent.getAdvisoryDestinations()); + destinations.setParent(parent.getDestinations()); + allDestinations.setParent(parent.getAllDestinations()); + } else { + advisoryDestinations.setParent(null); + destinations.setParent(null); + allDestinations.setParent(null); + } + } + +} diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java index 41b77b209c..26cfa6b156 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java @@ -99,6 +99,8 @@ public class PolicyEntry extends DestinationMapEntry { private boolean reduceMemoryFootprint; private NetworkBridgeFilterFactory networkBridgeFilterFactory; private boolean doOptimzeMessageStorage = true; + private int maxDestinations = -1; + /* * percentage of in-flight messages above which optimize message store is disabled */ @@ -962,4 +964,19 @@ public class PolicyEntry extends DestinationMapEntry { public boolean isPersistJMSRedelivered() { return persistJMSRedelivered; } + + public int getMaxDestinations() { + return maxDestinations; + } + + /** + * Sets the maximum number of destinations that can be created + * + * @param maxDestinations + * maximum number of destinations + */ + public void setMaxDestinations(int maxDestinations) { + this.maxDestinations = maxDestinations; + } + } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MaxDestinationsPolicyTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MaxDestinationsPolicyTest.java new file mode 100644 index 0000000000..714da18732 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MaxDestinationsPolicyTest.java @@ -0,0 +1,271 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.broker.policy; + +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.Topic; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.Lists; + +/** + * This unit test is to test that setting the property "maxDestinations" on + * PolicyEntry works correctly. If this property is set, it will limit the + * number of destinations that can be created. Advisory topics will be ignored + * during calculations. + * + */ +public class MaxDestinationsPolicyTest { + BrokerService broker; + ConnectionFactory factory; + Connection connection; + Session session; + MessageProducer producer; + + @Before + public void setUp() throws Exception { + broker = new BrokerService(); + + File testDataDir = new File("target/activemq-data/AMQ-5751"); + broker.setDataDirectoryFile(testDataDir); + broker.setUseJmx(true); + broker.setDeleteAllMessagesOnStartup(true); + broker.getSystemUsage().getMemoryUsage().setLimit(1024l * 1024 * 64); + KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); + persistenceAdapter.setDirectory(new File(testDataDir, "kahadb")); + broker.setPersistenceAdapter(persistenceAdapter); + broker.addConnector("tcp://localhost:0"); + broker.start(); + factory = new ActiveMQConnectionFactory(broker.getTransportConnectors() + .get(0).getConnectUri().toString()); + connection = factory.createConnection(); + connection.start(); + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + } + + @After + public void tearDown() throws Exception { + session.close(); + connection.stop(); + connection.close(); + broker.stop(); + } + + /** + * Test that 10 queues can be created when default policy allows it. + */ + @Test + public void testMaxDestinationDefaultPolicySuccess() throws Exception { + applyDefaultMaximumDestinationPolicy(10); + + for (int i = 0; i < 10; i++) { + createQueue("queue." + i); + } + } + + /** + * Test that default policy prevents going beyond max + */ + @Test(expected = javax.jms.IllegalStateException.class) + public void testMaxDestinationDefaultPolicyFail() throws Exception { + applyDefaultMaximumDestinationPolicy(10); + + for (int i = 0; i < 11; i++) { + createQueue("queue." + i); + } + } + + /** + * Test that a queue policy overrides the default policy + */ + @Test(expected = javax.jms.IllegalStateException.class) + public void testMaxDestinationOnQueuePolicy() throws Exception { + PolicyMap policyMap = applyDefaultMaximumDestinationPolicy(10); + applyMaximumDestinationPolicy(policyMap, new ActiveMQQueue("queue.>"), + 5); + + // This should fail even though the default policy is set to a limit of + // 10 because the + // queue policy overrides it + for (int i = 0; i < 6; i++) { + createQueue("queue." + i); + } + } + + /** + * Test that 10 topics can be created when default policy allows it. + */ + @Test + public void testTopicMaxDestinationDefaultPolicySuccess() throws Exception { + applyDefaultMaximumDestinationPolicy(10); + + for (int i = 0; i < 10; i++) { + createTopic("topic." + i); + } + } + + /** + * Test that topic creation will faill when exceeding the limit + */ + @Test(expected = javax.jms.IllegalStateException.class) + public void testTopicMaxDestinationDefaultPolicyFail() throws Exception { + applyDefaultMaximumDestinationPolicy(20); + + for (int i = 0; i < 21; i++) { + createTopic("topic." + i); + } + } + + /** + * Test that no limit is enforced + */ + @Test + public void testTopicDefaultPolicyNoMaxDestinations() throws Exception { + // -1 is the default and signals no max destinations + applyDefaultMaximumDestinationPolicy(-1); + for (int i = 0; i < 100; i++) { + createTopic("topic." + i); + } + } + + /** + * Test a mixture of queue and topic policies + */ + @Test + public void testComplexMaxDestinationPolicy() throws Exception { + PolicyMap policyMap = applyMaximumDestinationPolicy(new PolicyMap(), + new ActiveMQQueue("queue.>"), 5); + applyMaximumDestinationPolicy(policyMap, new ActiveMQTopic("topic.>"), + 10); + + for (int i = 0; i < 5; i++) { + createQueue("queue." + i); + } + + for (int i = 0; i < 10; i++) { + createTopic("topic." + i); + } + + // Make sure that adding one more of either a topic or a queue fails + boolean fail = false; + try { + createTopic("topic.test"); + } catch (javax.jms.IllegalStateException e) { + fail = true; + } + assertTrue(fail); + + fail = false; + try { + createQueue("queue.test"); + } catch (javax.jms.IllegalStateException e) { + fail = true; + } + assertTrue(fail); + } + + /** + * Test child destinations of a policy + */ + @Test + public void testMaxDestinationPolicyOnChildDests() throws Exception { + applyMaximumDestinationPolicy(new PolicyMap(), new ActiveMQTopic( + "topic.>"), 10); + + for (int i = 0; i < 10; i++) { + createTopic("topic.test" + i); + } + + // Make sure that adding one more fails + boolean fail = false; + try { + createTopic("topic.abc.test"); + } catch (javax.jms.IllegalStateException e) { + fail = true; + } + assertTrue(fail); + + } + + /** + * Test a topic policy overrides the default + */ + @Test(expected = javax.jms.IllegalStateException.class) + public void testMaxDestinationOnTopicPolicy() throws Exception { + PolicyMap policyMap = applyDefaultMaximumDestinationPolicy(10); + applyMaximumDestinationPolicy(policyMap, new ActiveMQTopic("topic.>"), + 5); + + // This should fail even though the default policy is set to a limit of + // 10 because the + // queue policy overrides it + for (int i = 0; i < 6; i++) { + createTopic("topic." + i); + } + } + + private PolicyMap applyMaximumDestinationPolicy(PolicyMap policyMap, + ActiveMQDestination destination, int maxDestinations) { + PolicyEntry entry = new PolicyEntry(); + entry.setDestination(destination); + entry.setMaxDestinations(maxDestinations); + policyMap.setPolicyEntries(Lists.newArrayList(entry)); + broker.setDestinationPolicy(policyMap); + return policyMap; + } + + private PolicyMap applyDefaultMaximumDestinationPolicy(int maxDestinations) { + PolicyMap policyMap = new PolicyMap(); + PolicyEntry defaultEntry = new PolicyEntry(); + if (maxDestinations >= 0) { + defaultEntry.setMaxDestinations(maxDestinations); + } + policyMap.setDefaultEntry(defaultEntry); + broker.setDestinationPolicy(policyMap); + return policyMap; + } + + private void createQueue(String queueName) throws Exception { + Queue queue = session.createQueue(queueName); + producer = session.createProducer(queue); + } + + private void createTopic(String topicName) throws Exception { + Topic topic = session.createTopic(topicName); + producer = session.createProducer(topic); + } + +} From 3100909041b8cf114773f0d0bf60d8032732186f Mon Sep 17 00:00:00 2001 From: gtully Date: Tue, 9 Jun 2015 11:29:20 +0100 Subject: [PATCH 05/52] https://issues.apache.org/jira/browse/AMQ-5830 - ensure duplex inbound connection sets network=true flag, fix and test --- .../apache/activemq/broker/BrokerService.java | 7 +- .../DemandForwardingBridgeSupport.java | 3 + .../network/NetworkBridgeFactory.java | 14 -- .../activemq/transport/vm/VMTransport.java | 9 - .../NetworkBridgeProducerFlowControlTest.java | 230 +++++++++++++++++- 5 files changed, 232 insertions(+), 31 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java index a2a04a050f..d285c74e4b 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -404,11 +404,7 @@ public class BrokerService implements Service { */ public NetworkConnector addNetworkConnector(NetworkConnector connector) throws Exception { connector.setBrokerService(this); - URI uri = getVmConnectorURI(); - Map map = new HashMap(URISupport.parseParameters(uri)); - map.put("network", "true"); - uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map)); - connector.setLocalUri(uri); + connector.setLocalUri(getVmConnectorURI()); // Set a connection filter so that the connector does not establish loop // back connections. connector.setConnectionFilter(new ConnectionFilter() { @@ -2499,7 +2495,6 @@ public class BrokerService implements Service { this.slave = false; URI uri = getVmConnectorURI(); Map map = new HashMap(URISupport.parseParameters(uri)); - map.put("network", "true"); map.put("async", "false"); uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map)); diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java index 1b77e73096..8ba1d98401 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java @@ -475,6 +475,9 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br if (configuration.isDuplex()) { // separate in-bound channel for forwards so we don't // contend with out-bound dispatch on same connection + remoteBrokerInfo.setNetworkConnection(true); + duplexInboundLocalBroker.oneway(remoteBrokerInfo); + ConnectionInfo duplexLocalConnectionInfo = new ConnectionInfo(); duplexLocalConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); duplexLocalConnectionInfo.setClientId(configuration.getName() + "_" + remoteBrokerName + "_inbound_duplex_" diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java index 41a9d9e7e9..0e938ae20f 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java @@ -32,19 +32,6 @@ public final class NetworkBridgeFactory { private NetworkBridgeFactory() { } - - /** - * Create a network bridge - * - * @param config - * @param localTransport - * @param remoteTransport - * @return the NetworkBridge - */ - public static DemandForwardingBridge createBridge(NetworkBridgeConfiguration config, - Transport localTransport, Transport remoteTransport) { - return createBridge(config, localTransport, remoteTransport, null); - } /** * create a network bridge @@ -74,7 +61,6 @@ public final class NetworkBridgeFactory { public static Transport createLocalTransport(Broker broker) throws Exception { URI uri = broker.getVmConnectorURI(); HashMap map = new HashMap(URISupport.parseParameters(uri)); - map.put("network", "true"); map.put("async", "true"); map.put("create", "false"); // we don't want a vm connect during shutdown to trigger a broker create uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map)); diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java index 6e6726defe..92c9c5178e 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java +++ b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java @@ -49,7 +49,6 @@ public class VMTransport implements Transport, Task { protected VMTransport peer; protected TransportListener transportListener; protected boolean marshal; - protected boolean network; protected boolean async = true; protected int asyncQueueDepth = 2000; protected final URI location; @@ -358,14 +357,6 @@ public class VMTransport implements Transport, Task { this.marshal = marshal; } - public boolean isNetwork() { - return network; - } - - public void setNetwork(boolean network) { - this.network = network; - } - @Override public String toString() { return location + "#" + id; diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java index e950b7dc85..4e1501d554 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java @@ -17,6 +17,7 @@ package org.apache.activemq.usecases; +import java.io.IOException; import java.net.URI; import java.util.Vector; import java.util.concurrent.CountDownLatch; @@ -31,7 +32,10 @@ import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.network.DiscoveryNetworkConnector; import org.apache.activemq.network.NetworkConnector; +import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent; import org.apache.activemq.util.MessageIdList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -242,7 +246,7 @@ public class NetworkBridgeProducerFlowControlTest extends // Verify the behaviour as described in the description of this class. if (networkIsAlwaysSendSync) { Assert - .assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 10); + .assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 20); } else { Assert.assertEquals(persistentTestMessages, @@ -384,4 +388,226 @@ public class NetworkBridgeProducerFlowControlTest extends // Verify the behaviour as described in the description of this class. Assert.assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 10); } -} \ No newline at end of file + + public void testSendFailIfNoSpaceReverseDoesNotBlockQueueNetwork() throws Exception { + final int NUM_MESSAGES = 100; + final long TEST_MESSAGE_SIZE = 1024; + final long SLOW_CONSUMER_DELAY_MILLIS = 100; + + final ActiveMQQueue slowDestination = new ActiveMQQueue( + NetworkBridgeProducerFlowControlTest.class.getSimpleName() + + ".slow.shared?consumer.prefetchSize=1"); + + final ActiveMQQueue fastDestination = new ActiveMQQueue( + NetworkBridgeProducerFlowControlTest.class.getSimpleName() + + ".fast.shared?consumer.prefetchSize=1"); + + + // Start a local and a remote broker. + BrokerService localBroker = createBroker(new URI("broker:(tcp://localhost:0" + + ")?brokerName=broker0&persistent=false&useJmx=true")); + createBroker(new URI( + "broker:(tcp://localhost:0" + + ")?brokerName=broker1&persistent=false&useJmx=true")); + localBroker.getSystemUsage().setSendFailIfNoSpace(true); + + // Set a policy on the local broker that limits the maximum size of the + // slow shared queue. + PolicyEntry policyEntry = new PolicyEntry(); + policyEntry.setMemoryLimit(5 * TEST_MESSAGE_SIZE); + PolicyMap policyMap = new PolicyMap(); + policyMap.put(slowDestination, policyEntry); + localBroker.setDestinationPolicy(policyMap); + + // Create an outbound bridge from the local broker to the remote broker. + // The bridge is configured with the remoteDispatchType enhancement. + NetworkConnector nc = bridgeBrokers("broker0", "broker1"); + nc.setAlwaysSyncSend(true); + nc.setPrefetchSize(1); + nc.setDuplex(true); + + startAllBrokers(); + waitForBridgeFormation(); + + // Start two asynchronous consumers on the local broker, one for each + // of the two shared queues, and keep track of how long it takes for + // each of the consumers to receive all the messages. + final CountDownLatch fastConsumerLatch = new CountDownLatch( + NUM_MESSAGES); + final CountDownLatch slowConsumerLatch = new CountDownLatch( + NUM_MESSAGES); + + final long startTimeMillis = System.currentTimeMillis(); + final AtomicLong fastConsumerTime = new AtomicLong(); + final AtomicLong slowConsumerTime = new AtomicLong(); + + Thread fastWaitThread = new Thread() { + @Override + public void run() { + try { + fastConsumerLatch.await(); + fastConsumerTime.set(System.currentTimeMillis() + - startTimeMillis); + } catch (InterruptedException ex) { + exceptions.add(ex); + Assert.fail(ex.getMessage()); + } + } + }; + + Thread slowWaitThread = new Thread() { + @Override + public void run() { + try { + slowConsumerLatch.await(); + slowConsumerTime.set(System.currentTimeMillis() + - startTimeMillis); + } catch (InterruptedException ex) { + exceptions.add(ex); + Assert.fail(ex.getMessage()); + } + } + }; + + fastWaitThread.start(); + slowWaitThread.start(); + + createConsumer("broker0", fastDestination, fastConsumerLatch); + MessageConsumer slowConsumer = createConsumer("broker0", + slowDestination, slowConsumerLatch); + MessageIdList messageIdList = brokers.get("broker0").consumers + .get(slowConsumer); + messageIdList.setProcessingDelay(SLOW_CONSUMER_DELAY_MILLIS); + + // Send the test messages to the local broker's shared queues. The + // messages are either persistent or non-persistent to demonstrate the + // difference between synchronous and asynchronous dispatch. + persistentDelivery = false; + sendMessages("broker1", fastDestination, NUM_MESSAGES); + sendMessages("broker1", slowDestination, NUM_MESSAGES); + + fastWaitThread.join(TimeUnit.SECONDS.toMillis(60)); + slowWaitThread.join(TimeUnit.SECONDS.toMillis(60)); + + assertTrue("no exceptions on the wait threads:" + exceptions, + exceptions.isEmpty()); + + LOG.info("Fast consumer duration (ms): " + fastConsumerTime.get()); + LOG.info("Slow consumer duration (ms): " + slowConsumerTime.get()); + + assertTrue("fast time set", fastConsumerTime.get() > 0); + assertTrue("slow time set", slowConsumerTime.get() > 0); + + // Verify the behaviour as described in the description of this class. + Assert.assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 10); + } + + + /** + * create a duplex network bridge from broker0 to broker1 + * add a topic consumer on broker0 + * set the setSendFailIfNoSpace() on the local broker. + * create a SimpleDiscoveryAgent impl that tracks a network reconnect + * + * producer connects to broker1 and messages should be sent across the network to broker0 + * + * Ensure broker0 will not send the javax.jms.ResourceAllocationException (when broker0 runs out of space). + * If the javax.jms.ResourceAllocationException is sent across the wire it will force the network connector + * to shutdown + * + * + * @throws Exception + */ + + public void testDuplexSendFailIfNoSpaceDoesNotBlockNetwork() throws Exception { + + // Consumer prefetch is disabled for broker1's consumers. + final ActiveMQTopic destination = new ActiveMQTopic( + NetworkBridgeProducerFlowControlTest.class.getSimpleName() + + ".duplexTest?consumer.prefetchSize=1"); + + final int NUM_MESSAGES = 100; + final long TEST_MESSAGE_SIZE = 1024; + final long SLOW_CONSUMER_DELAY_MILLIS = 100; + + // Start a local and a remote broker. + BrokerService localBroker = createBroker(new URI("broker:(tcp://localhost:0" + + ")?brokerName=broker0&persistent=false&useJmx=true")); + + BrokerService remoteBroker = createBroker(new URI( + "broker:(tcp://localhost:0" + + ")?brokerName=broker1&persistent=false&useJmx=true")); + + localBroker.getSystemUsage().setSendFailIfNoSpace(true); + + // Set a policy on the remote broker that limits the maximum size of the + // slow shared queue. + PolicyEntry policyEntry = new PolicyEntry(); + policyEntry.setMemoryLimit(5 * TEST_MESSAGE_SIZE); + PolicyMap policyMap = new PolicyMap(); + policyMap.put(destination, policyEntry); + localBroker.setDestinationPolicy(policyMap); + + // Create a duplex network bridge from the local broker to the remote broker + // create a SimpleDiscoveryAgent impl that tracks a reconnect + DiscoveryNetworkConnector discoveryNetworkConnector = (DiscoveryNetworkConnector)bridgeBrokers("broker0", "broker1"); + URI originURI = discoveryNetworkConnector.getUri(); + discoveryNetworkConnector.setAlwaysSyncSend(true); + discoveryNetworkConnector.setPrefetchSize(1); + discoveryNetworkConnector.setDuplex(true); + + DummySimpleDiscoveryAgent dummySimpleDiscoveryAgent = new DummySimpleDiscoveryAgent(); + dummySimpleDiscoveryAgent.setServices(originURI.toString().substring(8,originURI.toString().lastIndexOf(')'))); + + discoveryNetworkConnector.setDiscoveryAgent(dummySimpleDiscoveryAgent); + + startAllBrokers(); + waitForBridgeFormation(); + + + final CountDownLatch consumerLatch = new CountDownLatch( + NUM_MESSAGES); + + + //createConsumer("broker0", fastDestination, fastConsumerLatch); + + MessageConsumer consumer = createConsumer("broker0", + destination, consumerLatch); + + MessageIdList messageIdList = brokers.get("broker0").consumers + .get(consumer); + + messageIdList.setProcessingDelay(SLOW_CONSUMER_DELAY_MILLIS); + + // Send the test messages to the local broker's shared queues. The + // messages are either persistent or non-persistent to demonstrate the + // difference between synchronous and asynchronous dispatch. + persistentDelivery = false; + sendMessages("broker1", destination, NUM_MESSAGES); + + //wait for 5 seconds for the consumer to complete + consumerLatch.await(5, TimeUnit.SECONDS); + + assertFalse("dummySimpleDiscoveryAgent.serviceFail has been invoked - should not have been", + dummySimpleDiscoveryAgent.isServiceFailed); + + } + + /** + * When the network connector fails it records the failure and delegates to real SimpleDiscoveryAgent + */ + class DummySimpleDiscoveryAgent extends SimpleDiscoveryAgent { + + boolean isServiceFailed = false; + + public void serviceFailed(DiscoveryEvent devent) throws IOException { + + //should never get in here + LOG.info("!!!!! DummySimpleDiscoveryAgent.serviceFailed() invoked with event:"+devent+"!!!!!!"); + isServiceFailed = true; + super.serviceFailed(devent); + + } + + } +} From 789eb9abf9f6c01e58a6e65dc72006e778272660 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 10 Jun 2015 14:59:02 -0400 Subject: [PATCH 06/52] https://issues.apache.org/jira/browse/AMQ-5834 Ensure that a publish receives an ACK even when the user is not authorized to write to the target destination --- .../transport/mqtt/MQTTProtocolConverter.java | 67 +++++++++---------- .../activemq/transport/mqtt/MQTTAuthTest.java | 39 +++++++++++ 2 files changed, 70 insertions(+), 36 deletions(-) diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java index 39e9b84ee7..5bd1a3293a 100644 --- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java +++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java @@ -700,43 +700,38 @@ public class MQTTProtocolConverter { ResponseHandler createResponseHandler(final PUBLISH command) { if (command != null) { - switch (command.qos()) { - case AT_LEAST_ONCE: - return new ResponseHandler() { - @Override - public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException { - if (response.isException()) { - LOG.warn("Failed to send MQTT Publish: ", command, ((ExceptionResponse) response).getException()); - } else { - PUBACK ack = new PUBACK(); - ack.messageId(command.messageId()); - LOG.trace("MQTT Snd PUBACK message:{} client:{} connection:{}", - command.messageId(), clientId, connectionInfo.getConnectionId()); - converter.getMQTTTransport().sendToMQTT(ack.encode()); + return new ResponseHandler() { + @Override + public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException { + if (response.isException()) { + Throwable error = ((ExceptionResponse) response).getException(); + LOG.warn("Failed to send MQTT Publish: ", command, error.getMessage()); + LOG.trace("Error trace: {}", error); + } + + switch (command.qos()) { + case AT_LEAST_ONCE: + PUBACK ack = new PUBACK(); + ack.messageId(command.messageId()); + LOG.trace("MQTT Snd PUBACK message:{} client:{} connection:{}", + command.messageId(), clientId, connectionInfo.getConnectionId()); + converter.getMQTTTransport().sendToMQTT(ack.encode()); + break; + case EXACTLY_ONCE: + PUBREC req = new PUBREC(); + req.messageId(command.messageId()); + synchronized (publisherRecs) { + publisherRecs.put(command.messageId(), req); } - } - }; - case EXACTLY_ONCE: - return new ResponseHandler() { - @Override - public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException { - if (response.isException()) { - LOG.warn("Failed to send MQTT Publish: ", command, ((ExceptionResponse) response).getException()); - } else { - PUBREC ack = new PUBREC(); - ack.messageId(command.messageId()); - synchronized (publisherRecs) { - publisherRecs.put(command.messageId(), ack); - } - LOG.trace("MQTT Snd PUBACK message:{} client:{} connection:{}", - command.messageId(), clientId, connectionInfo.getConnectionId()); - converter.getMQTTTransport().sendToMQTT(ack.encode()); - } - } - }; - case AT_MOST_ONCE: - break; - } + LOG.trace("MQTT Snd PUBREC message:{} client:{} connection:{}", + command.messageId(), clientId, connectionInfo.getConnectionId()); + converter.getMQTTTransport().sendToMQTT(req.encode()); + break; + default: + break; + } + } + }; } return null; } diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java index 77942a08bd..7ffb3e80ab 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java @@ -196,6 +196,45 @@ public class MQTTAuthTest extends MQTTAuthTestSupport { assertNull(msg); } + @Test(timeout = 30 * 1000) + public void testPublishWhenNotAuthorizedDoesNotStall() throws Exception { + + getProxyToBroker().addTopic("USERS.foo"); + + MQTT mqtt = null; + BlockingConnection connection = null; + + // Test 3.1 functionality + mqtt = createMQTTConnection("pub", true); + mqtt.setUserName("guest"); + mqtt.setPassword("password"); + mqtt.setVersion("3.1"); + + connection = mqtt.blockingConnection(); + connection.connect(); + connection.publish("USERS.foo", "test-AT_MOST_ONCE".getBytes(), QoS.AT_MOST_ONCE, true); + connection.publish("USERS.foo", "test-AT_LEAST_ONCE".getBytes(), QoS.AT_LEAST_ONCE, true); + connection.publish("USERS.foo", "test-EXACTLY_ONCE".getBytes(), QoS.EXACTLY_ONCE, true); + connection.disconnect(); + + assertEquals(0, getProxyToTopic("USERS.foo").getEnqueueCount()); + + // Test 3.1.1 functionality + mqtt = createMQTTConnection("pub", true); + mqtt.setUserName("guest"); + mqtt.setPassword("password"); + mqtt.setVersion("3.1.1"); + + connection = mqtt.blockingConnection(); + connection.connect(); + connection.publish("USERS.foo", "test-AT_MOST_ONCE".getBytes(), QoS.AT_MOST_ONCE, true); + connection.publish("USERS.foo", "test-AT_LEAST_ONCE".getBytes(), QoS.AT_LEAST_ONCE, true); + connection.publish("USERS.foo", "test-EXACTLY_ONCE".getBytes(), QoS.EXACTLY_ONCE, true); + connection.disconnect(); + + assertEquals(0, getProxyToTopic("USERS.foo").getEnqueueCount()); + } + @Test(timeout = 60 * 1000) public void testWildcardRetainedSubscription() throws Exception { MQTT mqttPub = createMQTTConnection("pub", true); From ce16735bb07e9df5e280c9cd9f82b331ee284f24 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 10 Jun 2015 18:21:31 -0400 Subject: [PATCH 07/52] Test needs more wait time on redelivery check since the initial redelivery delay is 4 seconds and the sleep was only 3s + 500ms receive. --- .../activemq/broker/BrokerRedeliveryTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java index 4320ade1ae..916a655d45 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java @@ -17,13 +17,14 @@ package org.apache.activemq.broker; import java.util.concurrent.TimeUnit; + import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; + import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.ActiveMQPrefetchPolicy; import org.apache.activemq.RedeliveryPolicy; import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap; import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy; @@ -71,13 +72,13 @@ public class BrokerRedeliveryTest extends org.apache.activemq.TestSupport { LOG.info("got: " + message); consumerSession.rollback(); - for (int i=0;i Date: Fri, 12 Jun 2015 12:25:35 +0100 Subject: [PATCH 08/52] fix incorrect warn message about lease duration and keep alive --- .../org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java index 9dce47ee79..e03fbc45da 100644 --- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java +++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java @@ -48,7 +48,7 @@ public class LeaseDatabaseLocker extends AbstractJDBCLocker { if (lockAcquireSleepInterval < lockable.getLockKeepAlivePeriod()) { LOG.warn("LockableService keep alive period: " + lockable.getLockKeepAlivePeriod() - + ", which renews the lease, is less than lockAcquireSleepInterval: " + lockAcquireSleepInterval + + ", which renews the lease, is greater than lockAcquireSleepInterval: " + lockAcquireSleepInterval + ", the lease duration. These values will allow the lease to expire."); } From 61fd811adcb416ca1810dac81ef33e39e8722537 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Tue, 9 Jun 2015 19:40:16 +0000 Subject: [PATCH 09/52] https://issues.apache.org/jira/browse/AMQ-5393 Adding a property called schedulePeriodForDiskUsageCheck which can be set to a time period to periodically check disk usage limits and adjust if the amount of disk space has been reduced. --- .../apache/activemq/broker/BrokerService.java | 79 ++++++-- .../usage/PeriodicDiskUsageLimitTest.java | 185 ++++++++++++++++++ 2 files changed, 253 insertions(+), 11 deletions(-) create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/usage/PeriodicDiskUsageLimitTest.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java index d285c74e4b..6148d38382 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -229,6 +229,7 @@ public class BrokerService implements Service { private ThreadPoolExecutor executor; private int schedulePeriodForDestinationPurge= 0; private int maxPurgedDestinationsPerSweep = 0; + private int schedulePeriodForDiskUsageCheck = 0; private BrokerContext brokerContext; private boolean networkConnectorStartAsync = false; private boolean allowTempAutoCreationOnSend; @@ -1953,17 +1954,12 @@ public class BrokerService implements Service { } } - protected void checkSystemUsageLimits() throws IOException { - SystemUsage usage = getSystemUsage(); - long memLimit = usage.getMemoryUsage().getLimit(); - long jvmLimit = Runtime.getRuntime().maxMemory(); - - if (memLimit > jvmLimit) { - usage.getMemoryUsage().setPercentOfJvmHeap(70); - LOG.warn("Memory Usage for the Broker (" + memLimit / (1024 * 1024) + - " mb) is more than the maximum available for the JVM: " + - jvmLimit / (1024 * 1024) + " mb - resetting to 70% of maximum available: " + (usage.getMemoryUsage().getLimit() / (1024 * 1024)) + " mb"); - } + /** + * Check that the store usage limit is not greater than max usable + * space and adjust if it is + */ + protected void checkStoreUsageLimits() throws IOException { + final SystemUsage usage = getSystemUsage(); if (getPersistenceAdapter() != null) { PersistenceAdapter adapter = getPersistenceAdapter(); @@ -2007,6 +2003,14 @@ public class BrokerService implements Service { } } + } + + /** + * Check that temporary usage limit is not greater than max usable + * space and adjust if it is + */ + protected void checkTmpStoreUsageLimits() throws IOException { + final SystemUsage usage = getSystemUsage(); File tmpDir = getTmpDataDirectory(); if (tmpDir != null) { @@ -2047,6 +2051,54 @@ public class BrokerService implements Service { } } } + } + + /** + * Schedules a periodic task based on schedulePeriodForDiskLimitCheck to + * update store and temporary store limits if the amount of available space + * plus current store size is less than the existin configured limit + */ + protected void scheduleDiskUsageLimitsCheck() throws IOException { + if (schedulePeriodForDiskUsageCheck > 0 && + (getPersistenceAdapter() != null || getTmpDataDirectory() != null)) { + Runnable diskLimitCheckTask = new Runnable() { + @Override + public void run() { + try { + checkStoreUsageLimits(); + } catch (IOException e) { + LOG.error("Failed to check persistent disk usage limits", e); + } + + try { + checkTmpStoreUsageLimits(); + } catch (IOException e) { + LOG.error("Failed to check temporary store usage limits", e); + } + } + }; + scheduler.executePeriodically(diskLimitCheckTask, schedulePeriodForDiskUsageCheck); + } + } + + protected void checkSystemUsageLimits() throws IOException { + final SystemUsage usage = getSystemUsage(); + long memLimit = usage.getMemoryUsage().getLimit(); + long jvmLimit = Runtime.getRuntime().maxMemory(); + + if (memLimit > jvmLimit) { + usage.getMemoryUsage().setPercentOfJvmHeap(70); + LOG.warn("Memory Usage for the Broker (" + memLimit / (1024 * 1024) + + " mb) is more than the maximum available for the JVM: " + + jvmLimit / (1024 * 1024) + " mb - resetting to 70% of maximum available: " + (usage.getMemoryUsage().getLimit() / (1024 * 1024)) + " mb"); + } + + //Check the persistent store and temp store limits if they exist + //and schedule a periodic check to update disk limits if + //schedulePeriodForDiskLimitCheck is set + checkStoreUsageLimits(); + checkTmpStoreUsageLimits(); + scheduleDiskUsageLimitsCheck(); if (getJobSchedulerStore() != null) { JobSchedulerStore scheduler = getJobSchedulerStore(); @@ -2837,6 +2889,11 @@ public class BrokerService implements Service { this.schedulePeriodForDestinationPurge = schedulePeriodForDestinationPurge; } + public void setSchedulePeriodForDiskUsageCheck( + int schedulePeriodForDiskUsageCheck) { + this.schedulePeriodForDiskUsageCheck = schedulePeriodForDiskUsageCheck; + } + public int getMaxPurgedDestinationsPerSweep() { return this.maxPurgedDestinationsPerSweep; } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usage/PeriodicDiskUsageLimitTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usage/PeriodicDiskUsageLimitTest.java new file mode 100644 index 0000000000..bd3687b6f0 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usage/PeriodicDiskUsageLimitTest.java @@ -0,0 +1,185 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.usage; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Random; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.store.PersistenceAdapter; +import org.apache.activemq.usage.StoreUsage; +import org.apache.activemq.usage.SystemUsage; +import org.apache.activemq.usage.TempUsage; +import org.apache.activemq.util.Wait; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * This test is for AMQ-5393 and will check that schedulePeriodForDiskLimitCheck + * properly schedules a task that will update disk limits if the amount of usable disk space drops + * because another process uses up disk space. + * + */ +public class PeriodicDiskUsageLimitTest { + protected static final Logger LOG = LoggerFactory + .getLogger(PeriodicDiskUsageLimitTest.class); + + File dataFileDir = new File("target/test-amq-5393/datadb"); + File testfile = new File("target/test-amq-5393/testfile"); + private BrokerService broker; + private PersistenceAdapter adapter; + private TempUsage tempUsage; + private StoreUsage storeUsage; + + @Before + public void setUpBroker() throws Exception { + broker = new BrokerService(); + broker.setPersistent(true); + broker.setDataDirectoryFile(dataFileDir); + broker.setDeleteAllMessagesOnStartup(true); + adapter = broker.getPersistenceAdapter(); + + FileUtils.deleteQuietly(testfile); + FileUtils.forceMkdir(adapter.getDirectory()); + FileUtils.forceMkdir(broker.getTempDataStore().getDirectory()); + + final SystemUsage systemUsage = broker.getSystemUsage(); + tempUsage = systemUsage.getTempUsage(); + storeUsage = systemUsage.getStoreUsage(); + } + + protected void startBroker() throws Exception { + broker.start(); + broker.waitUntilStarted(); + } + + @After + public void stopBroker() throws Exception { + broker.stop(); + broker.waitUntilStopped(); + FileUtils.deleteQuietly(testfile); + FileUtils.deleteQuietly(dataFileDir); + } + + /** + * This test will show that if a file is written to take away free space, and + * if the usage limit is now less than the store size plus remaining free space, then + * the usage limits will adjust lower. + */ + @Test(timeout=30000) + public void testDiskUsageAdjustLower() throws Exception { + //set the limit to max space so that if a file is added to eat up free space then + //the broker should adjust the usage limit..set time to 5 seconds for testing + setLimitMaxSpace(); + broker.setSchedulePeriodForDiskUsageCheck(4000); + startBroker(); + + final long originalDisk = broker.getSystemUsage().getStoreUsage().getLimit(); + final long originalTmp = broker.getSystemUsage().getTempUsage().getLimit(); + + //write a 1 meg file to the file system + writeTestFile(1024 * 1024); + + //Assert that the usage limits have been decreased because some free space was used + //up by a file + assertTrue("Store Usage should ramp down.", Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return broker.getSystemUsage().getStoreUsage().getLimit() < originalDisk; + } + })); + + assertTrue("Temp Usage should ramp down.", Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return broker.getSystemUsage().getTempUsage().getLimit() < originalTmp; + } + })); + } + + /** + * This test shows that the usage limits will not change if the + * schedulePeriodForDiskLimitCheck property is not set because no task will run + */ + @Test(timeout=30000) + public void testDiskLimitCheckNotSet() throws Exception { + setLimitMaxSpace(); + startBroker(); + + long originalDisk = broker.getSystemUsage().getStoreUsage().getLimit(); + long originalTmp = broker.getSystemUsage().getTempUsage().getLimit(); + + //write a 1 meg file to the file system + writeTestFile(1024 * 1024); + Thread.sleep(3000); + + //assert that the usage limits have not changed because a task should not have run + assertEquals(originalDisk, broker.getSystemUsage().getStoreUsage().getLimit()); + assertEquals(originalTmp, broker.getSystemUsage().getTempUsage().getLimit()); + } + + /** + * This test will show that if a file is written to take away free space, but + * if the limit is greater than the store size and the remaining free space, then + * the usage limits will not adjust. + */ + @Test(timeout=30000) + public void testDiskUsageStaySame() throws Exception { + //set a limit lower than max available space and set the period to 5 seconds + tempUsage.setLimit(10000000); + storeUsage.setLimit(100000000); + broker.setSchedulePeriodForDiskUsageCheck(2000); + startBroker(); + + long originalDisk = broker.getSystemUsage().getStoreUsage().getLimit(); + long originalTmp = broker.getSystemUsage().getTempUsage().getLimit(); + + //write a 1 meg file to the file system + writeTestFile(1024 * 1024); + Thread.sleep(5000); + + //Assert that the usage limits have not changed because writing a 1 meg file + //did not decrease the the free space below the already set limit + assertEquals(originalDisk, broker.getSystemUsage().getStoreUsage().getLimit()); + assertEquals(originalTmp, broker.getSystemUsage().getTempUsage().getLimit()); + } + + protected void setLimitMaxSpace() { + //Configure store limits to be the max usable space on startup + tempUsage.setLimit(broker.getTempDataStore().getDirectory().getUsableSpace()); + storeUsage.setLimit(adapter.getDirectory().getUsableSpace()); + } + + protected void writeTestFile(int size) throws IOException { + final byte[] data = new byte[size]; + final Random rng = new Random(); + rng.nextBytes(data); + IOUtils.write(data, new FileOutputStream(testfile)); + } + +} From ab389684be1f6da3a0887f1f1392f3399b1aca0d Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon" Date: Thu, 11 Jun 2015 21:35:33 -0400 Subject: [PATCH 10/52] https://issues.apache.org/jira/browse/AMQ-5836 Modifying start up scripts to consistently use the same property names --- assembly/src/release/bin/activemq-admin | 10 +++++----- assembly/src/release/bin/activemq-admin.bat | 6 +++--- assembly/src/release/bin/activemq.bat | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/assembly/src/release/bin/activemq-admin b/assembly/src/release/bin/activemq-admin index cbe2aef585..eff43ddd70 100644 --- a/assembly/src/release/bin/activemq-admin +++ b/assembly/src/release/bin/activemq-admin @@ -151,15 +151,15 @@ if [ ""$1 = "start" ] ; then ACTIVEMQ_OPTS="-Xmx1G -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" fi - if [ -z "$SUNJMX" ] ; then - #SUNJMX="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" - SUNJMX="-Dcom.sun.management.jmxremote" + if [ -z "$ACTIVEMQ_SUNJMX_START" ] ; then + #ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" + ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote" fi - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $SUNJMX -Djava.io.tmpdir="${ACTIVEMQ_TMP}"" + ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_SUNJMX_START -Djava.io.tmpdir="${ACTIVEMQ_TMP}"" fi -ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $SSL_OPTS" +ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_SSL_OPTS" # Uncomment to enable YourKit profiling #ACTIVEMQ_DEBUG_OPTS="-agentlib:yjpagent" diff --git a/assembly/src/release/bin/activemq-admin.bat b/assembly/src/release/bin/activemq-admin.bat index 6327826111..35a5ffbd97 100644 --- a/assembly/src/release/bin/activemq-admin.bat +++ b/assembly/src/release/bin/activemq-admin.bat @@ -82,8 +82,8 @@ if /i not "%1" == "start" goto debugOpts if "%ACTIVEMQ_OPTS%" == "" set ACTIVEMQ_OPTS=-Xmx1G -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=%ACTIVEMQ_CONF%\login.config -if "%SUNJMX%" == "" set SUNJMX=-Dcom.sun.management.jmxremote -REM set SUNJMX=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false +if "%ACTIVEMQ_SUNJMX_START%" == "" set ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote +REM set ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false :debugOpts @@ -95,7 +95,7 @@ REM SET ACTIVEMQ_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:tra REM Setup ActiveMQ Classpath. Default is the conf directory. set ACTIVEMQ_CLASSPATH=%ACTIVEMQ_CONF%;%ACTIVEMQ_DATA%;%ACTIVEMQ_CLASSPATH% -"%_JAVACMD%" %SUNJMX% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* +"%_JAVACMD%" %ACTIVEMQ_SUNJMX_START% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %ACTIVEMQ_SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* goto end diff --git a/assembly/src/release/bin/activemq.bat b/assembly/src/release/bin/activemq.bat index 276bfabcee..22e1f9da4b 100755 --- a/assembly/src/release/bin/activemq.bat +++ b/assembly/src/release/bin/activemq.bat @@ -79,8 +79,8 @@ if "%ACTIVEMQ_TMP%" == "" set ACTIVEMQ_TMP=%ACTIVEMQ_DATA%\tmp if "%ACTIVEMQ_OPTS%" == "" set ACTIVEMQ_OPTS=-Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=%ACTIVEMQ_CONF%\login.config -if "%SUNJMX%" == "" set SUNJMX=-Dcom.sun.management.jmxremote -REM set SUNJMX=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false +if "%ACTIVEMQ_SUNJMX_START%" == "" set ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote +REM set ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false REM Uncomment to enable YourKit profiling REM SET ACTIVEMQ_DEBUG_OPTS="-agentlib:yjpagent" @@ -92,7 +92,7 @@ REM Setup ActiveMQ Classpath. REM Add instance conf dir before AMQ install conf dir to pick up instance-specific classpath entries first set ACTIVEMQ_CLASSPATH=%ACTIVEMQ_CONF%;%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_CLASSPATH% -"%_JAVACMD%" %SUNJMX% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* +"%_JAVACMD%" %ACTIVEMQ_SUNJMX_START% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %ACTIVEMQ_SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* goto end From d723d14acb4f87c312804cabe61c7786e971396d Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 12 Jun 2015 14:26:04 -0400 Subject: [PATCH 11/52] Add some additional control over what is configured on the running broker. --- .../activemq/transport/amqp/IDERunner.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/IDERunner.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/IDERunner.java index ab64f2116e..70676056ec 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/IDERunner.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/IDERunner.java @@ -28,6 +28,8 @@ public class IDERunner { private static final String AMQP_TRANSFORMER = "jms"; private static final boolean TRANSPORT_TRACE = true; + private static final boolean PERSISTENT = true; + private static final boolean CLIENT_CONNECT = false; public static void main(String[]args) throws Exception { BrokerService brokerService = new BrokerService(); @@ -40,15 +42,23 @@ public class IDERunner { KahaDBStore store = new KahaDBStore(); store.setDirectory(new File("target/activemq-data/kahadb")); - brokerService.setStoreOpenWireVersion(10); - brokerService.setPersistenceAdapter(store); + if (PERSISTENT) { + brokerService.setStoreOpenWireVersion(10); + brokerService.setPersistenceAdapter(store); + brokerService.deleteAllMessages(); + } else { + brokerService.setPersistent(false); + } + brokerService.setUseJmx(false); - brokerService.deleteAllMessages(); + brokerService.setAdvisorySupport(false); brokerService.start(); - Connection connection = JMSClientContext.INSTANCE.createConnection(connector.getPublishableConnectURI()); - connection.start(); + if (CLIENT_CONNECT) { + Connection connection = JMSClientContext.INSTANCE.createConnection(connector.getPublishableConnectURI()); + connection.start(); + } brokerService.waitUntilStopped(); } From d74c0871347b509a610d585188f61142e3d06b50 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 12 Jun 2015 15:39:17 -0400 Subject: [PATCH 12/52] Add a negative validation test. --- .../amqp/interop/AmqpSendReceiveTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java index 29ff954b0f..906febf73c 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java @@ -19,6 +19,7 @@ package org.apache.activemq.transport.amqp.interop; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.concurrent.TimeUnit; @@ -86,23 +87,29 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { AmqpConnection connection = client.connect(); AmqpSession session = connection.createSession(); - AmqpMessage message = new AmqpMessage(); + AmqpMessage message1 = new AmqpMessage(); + message1.setGroupId("abcdefg"); + message1.setApplicationProperty("sn", 100); - message.setGroupId("abcdefg"); - message.setApplicationProperty("sn", 100); + AmqpMessage message2 = new AmqpMessage(); + message2.setGroupId("hijklm"); + message2.setApplicationProperty("sn", 200); AmqpSender sender = session.createSender("queue://" + getTestName()); - sender.send(message); + sender.send(message1); + sender.send(message2); sender.close(); AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), "sn = 100"); - receiver.flow(1); + receiver.flow(2); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(received); assertEquals(100, received.getApplicationProperty("sn")); assertEquals("abcdefg", received.getGroupId()); received.accept(); + assertNull(receiver.receive(1, TimeUnit.SECONDS)); + receiver.close(); } From 4945c83d708eb5fe6c6a44cb0e73e96f495da9a5 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 12 Jun 2015 16:11:55 -0400 Subject: [PATCH 13/52] https://issues.apache.org/jira/browse/AMQ-5839 Use correct name for the no-local filter --- .../java/org/apache/activemq/transport/amqp/AmqpSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java index 0579fcf57f..0d3f733253 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java @@ -38,7 +38,7 @@ public class AmqpSupport { public static final Symbol JMS_SELECTOR_NAME = Symbol.valueOf("apache.org:selector-filter:string"); public static final Object[] JMS_SELECTOR_FILTER_IDS = new Object[] { JMS_SELECTOR_CODE, JMS_SELECTOR_NAME }; public static final UnsignedLong NO_LOCAL_CODE = UnsignedLong.valueOf(0x0000468C00000003L); - public static final Symbol NO_LOCAL_NAME = Symbol.valueOf("apache.org:selector-filter:string"); + public static final Symbol NO_LOCAL_NAME = Symbol.valueOf("apache.org:no-local-filter:list"); public static final Object[] NO_LOCAL_FILTER_IDS = new Object[] { NO_LOCAL_CODE, NO_LOCAL_NAME }; // Capabilities used to identify destination type in some requests. From 732fd5684017cd585bfb418950a03ec9a6f44e49 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 12 Jun 2015 16:43:34 -0400 Subject: [PATCH 14/52] https://issues.apache.org/jira/browse/AMQ-5839 Disable failing test, broker doesn't currently recover the noLocal state for a durable subscription. --- .../transport/amqp/interop/AmqpDurableReceiverTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java index e2d24959da..1b944a983e 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java @@ -35,6 +35,7 @@ import org.apache.qpid.proton.amqp.messaging.Source; import org.apache.qpid.proton.amqp.messaging.TerminusDurability; import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy; import org.apache.qpid.proton.engine.Receiver; +import org.junit.Ignore; import org.junit.Test; /** @@ -292,6 +293,7 @@ public class AmqpDurableReceiverTest extends AmqpClientTestSupport { connection.close(); } + @Ignore("Broker doesn't currently recover noLocal state") @Test(timeout = 60000) public void testLookupExistingSubscriptionAfterRestartWithSelectorAndNoLocal() throws Exception { From e2221e31fa4ffef524d0026fa1d26728152be56b Mon Sep 17 00:00:00 2001 From: Dejan Bosanac Date: Mon, 15 Jun 2015 12:30:13 +0200 Subject: [PATCH 15/52] https://issues.apache.org/jira/browse/AMQ-5841 - activemq script returns a non zero exit code for successful operations --- .../src/main/java/org/apache/activemq/console/Main.java | 8 ++++---- .../org/apache/activemq/console/command/ShellCommand.java | 2 +- assembly/src/release/bin/activemq | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activemq-console/src/main/java/org/apache/activemq/console/Main.java b/activemq-console/src/main/java/org/apache/activemq/console/Main.java index a4dfe0ba6d..67c2562a35 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/Main.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/Main.java @@ -112,8 +112,8 @@ public class Main { app.addClassPathList(System.getProperty("activemq.classpath")); try { - app.runTaskClass(tokens); - System.exit(0); + int ret = app.runTaskClass(tokens); + System.exit(ret); } catch (ClassNotFoundException e) { System.out.println("Could not load class: " + e.getMessage()); try { @@ -216,7 +216,7 @@ public class Main { } - public void runTaskClass(List tokens) throws Throwable { + public int runTaskClass(List tokens) throws Throwable { StringBuilder buffer = new StringBuilder(); buffer.append(System.getProperty("java.vendor")); @@ -259,7 +259,7 @@ public class Main { Method runTask = task.getMethod("main", new Class[] { String[].class, InputStream.class, PrintStream.class }); - runTask.invoke(task.newInstance(), args, System.in, System.out); + return (int)runTask.invoke(task.newInstance(), args, System.in, System.out); } catch (InvocationTargetException e) { throw e.getCause(); } diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java index ad6bfc5c39..61ee2072c4 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java @@ -105,7 +105,7 @@ public class ShellCommand extends AbstractCommand { return 0; } catch (Exception e) { context.printException(e); - return -1; + return 1; } } diff --git a/assembly/src/release/bin/activemq b/assembly/src/release/bin/activemq index 100e0cd638..de448dabba 100755 --- a/assembly/src/release/bin/activemq +++ b/assembly/src/release/bin/activemq @@ -538,7 +538,7 @@ invoke_task(){ exit $? else invokeJar - exit 1 + exit $? fi } From 1d0f0d541aa8e158bbb48b607ccedaf35940494f Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Mon, 15 Jun 2015 09:09:52 -0400 Subject: [PATCH 16/52] https://issues.apache.org/jira/browse/AMQ-5606 Move to v0.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index daadb188ff..048b33327e 100755 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ 1.4.0 3.4.6 0.9.1 - 0.2.0 + 0.3.0 4.0.17.Final 1.3 1.0 From 33fb7c6096c0786997f76caccd0c4e3e02e40a33 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Mon, 15 Jun 2015 10:18:28 -0400 Subject: [PATCH 17/52] https://issues.apache.org/jira/browse/AMQ-5621 Have the test store its data in the target folder to let the clean step remove it and attempt to remove the data folder between runs to avoid state derby instances. --- .../org/apache/activemq/bugs/AMQ5567Test.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java index c0e1c1470e..a17d3f887a 100755 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java @@ -18,11 +18,14 @@ package org.apache.activemq.bugs; import java.io.File; import java.util.concurrent.TimeUnit; + import javax.jms.JMSException; import javax.jms.TextMessage; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; + import junit.framework.Test; + import org.apache.activemq.broker.BrokerRestartTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.StubConnection; @@ -46,8 +49,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AMQ5567Test extends BrokerRestartTestSupport { + protected static final Logger LOG = LoggerFactory.getLogger(AMQ5567Test.class); - ActiveMQQueue destination = new ActiveMQQueue("Q"); + + private final ActiveMQQueue destination = new ActiveMQQueue("Q"); + private final String DATA_FOLDER = "./target/AMQ5567Test-data"; @Override protected void configureBroker(BrokerService broker) throws Exception { @@ -55,12 +61,19 @@ public class AMQ5567Test extends BrokerRestartTestSupport { broker.setPersistenceAdapter(persistenceAdapter); } + @Override protected PolicyEntry getDefaultPolicy() { PolicyEntry policy = new PolicyEntry(); policy.setMemoryLimit(60*1024); return policy; } + @Override + protected void tearDown() throws Exception { + super.tearDown(); + IOHelper.delete(new File(DATA_FOLDER)); + } + public void initCombosForTestPreparedTransactionNotDispatched() throws Exception { PersistenceAdapter[] persistenceAdapters = new PersistenceAdapter[]{ new KahaDBPersistenceAdapter(), @@ -68,7 +81,7 @@ public class AMQ5567Test extends BrokerRestartTestSupport { new JDBCPersistenceAdapter() }; for (PersistenceAdapter adapter : persistenceAdapters) { - adapter.setDirectory(new File(IOHelper.getDefaultDataDirectory())); + adapter.setDirectory(new File(DATA_FOLDER)); } addCombinationValues("persistenceAdapter", persistenceAdapters); } From 151e25117b0ae7901cb663f2d7b8194d5a38fb0b Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Fri, 12 Jun 2015 09:55:41 +0100 Subject: [PATCH 18/52] https://issues.apache.org/jira/browse/AMQ-5400 improved the patch because of some test failures --- .../org/apache/activemq/ActiveMQSession.java | 244 ++++++++++-------- 1 file changed, 142 insertions(+), 102 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java index 2e0f6468fa..ec6e1a1819 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java @@ -200,6 +200,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta } private static final Logger LOG = LoggerFactory.getLogger(ActiveMQSession.class); + private static final Object REDELIVERY_GUARD = new Object(); private final ThreadPoolExecutor connectionExecutor; protected int acknowledgementMode; @@ -916,125 +917,164 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta lastDeliveredSequenceId = message.getMessageId().getBrokerSequenceId(); final MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1); - try { - ack.setFirstMessageId(md.getMessage().getMessageId()); - doStartTransaction(); - ack.setTransactionId(getTransactionContext().getTransactionId()); - if (ack.getTransactionId() != null) { - getTransactionContext().addSynchronization(new Synchronization() { - final int clearRequestCount = (clearRequestsCounter.get() == Integer.MAX_VALUE ? clearRequestsCounter.incrementAndGet() : clearRequestsCounter.get()); - @Override - public void beforeEnd() throws Exception { - // validate our consumer so we don't push stale acks that get ignored - if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { - LOG.debug("forcing rollback - {} consumer no longer active on {}", ack, connection); - throw new TransactionRolledBackException("consumer " + ack.getConsumerId() + " no longer active on " + connection); - } - LOG.trace("beforeEnd ack {}", ack); - sendAck(ack); - } + final AtomicBoolean afterDeliveryError = new AtomicBoolean(false); + /* + * The redelivery guard is to allow the endpoint lifecycle to complete before the messsage is dispatched. + * We dont want the after deliver being called after the redeliver as it may cause some weird stuff. + * */ + synchronized (REDELIVERY_GUARD) { + try { + ack.setFirstMessageId(md.getMessage().getMessageId()); + doStartTransaction(); + ack.setTransactionId(getTransactionContext().getTransactionId()); + if (ack.getTransactionId() != null) { + getTransactionContext().addSynchronization(new Synchronization() { - @Override - public void afterRollback() throws Exception { - LOG.trace("rollback {}", ack, new Throwable("here")); - // ensure we don't filter this as a duplicate - connection.rollbackDuplicate(ActiveMQSession.this, md.getMessage()); + final int clearRequestCount = (clearRequestsCounter.get() == Integer.MAX_VALUE ? clearRequestsCounter.incrementAndGet() : clearRequestsCounter.get()); - // don't redeliver if we have been interrupted b/c the broker will redeliver on reconnect - if (clearRequestsCounter.get() > clearRequestCount) { - LOG.debug("No redelivery of {} on rollback of {} due to failover of {}", md, ack.getTransactionId(), connection.getTransport()); - return; - } - - // validate our consumer so we don't push stale acks that get ignored or redeliver what will be redispatched - if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { - LOG.debug("No local redelivery of {} on rollback of {} because consumer is no longer active on {}", md, ack.getTransactionId(), connection.getTransport()); - return; - } - - RedeliveryPolicy redeliveryPolicy = connection.getRedeliveryPolicy(); - int redeliveryCounter = md.getMessage().getRedeliveryCounter(); - if (redeliveryPolicy.getMaximumRedeliveries() != RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES - && redeliveryCounter >= redeliveryPolicy.getMaximumRedeliveries()) { - // We need to NACK the messages so that they get - // sent to the - // DLQ. - // Acknowledge the last message. - MessageAck ack = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1); - ack.setFirstMessageId(md.getMessage().getMessageId()); - ack.setPoisonCause(new Throwable("Exceeded ra redelivery policy limit:" + redeliveryPolicy)); - asyncSendPacket(ack); - - } else { - - MessageAck ack = new MessageAck(md, MessageAck.REDELIVERED_ACK_TYPE, 1); - ack.setFirstMessageId(md.getMessage().getMessageId()); - asyncSendPacket(ack); - - // Figure out how long we should wait to resend - // this message. - long redeliveryDelay = redeliveryPolicy.getInitialRedeliveryDelay(); - for (int i = 0; i < redeliveryCounter; i++) { - redeliveryDelay = redeliveryPolicy.getNextRedeliveryDelay(redeliveryDelay); + @Override + public void beforeEnd() throws Exception { + // validate our consumer so we don't push stale acks that get ignored + if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { + LOG.debug("forcing rollback - {} consumer no longer active on {}", ack, connection); + throw new TransactionRolledBackException("consumer " + ack.getConsumerId() + " no longer active on " + connection); } - - if ( connection.isNonBlockingRedelivery() == false) { - LOG.debug("Blocking session until re-delivery..."); - executor.stop(); - } - - connection.getScheduler().executeAfterDelay(new Runnable() { + LOG.trace("beforeEnd ack {}", ack); + sendAck(ack); + } - @Override - public void run() { - - if (connection.isNonBlockingRedelivery()) { - ((ActiveMQDispatcher)md.getConsumer()).dispatch(md); - } else { - LOG.debug("Session released, issuing re-delivery..."); - executor.executeFirst(md); - executor.start(); - } + @Override + public void afterRollback() throws Exception { + LOG.trace("rollback {}", ack, new Throwable("here")); + // ensure we don't filter this as a duplicate + connection.rollbackDuplicate(ActiveMQSession.this, md.getMessage()); + + // don't redeliver if we have been interrupted b/c the broker will redeliver on reconnect + if (clearRequestsCounter.get() > clearRequestCount) { + LOG.debug("No redelivery of {} on rollback of {} due to failover of {}", md, ack.getTransactionId(), connection.getTransport()); + return; + } + + // validate our consumer so we don't push stale acks that get ignored or redeliver what will be redispatched + if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { + LOG.debug("No local redelivery of {} on rollback of {} because consumer is no longer active on {}", md, ack.getTransactionId(), connection.getTransport()); + return; + } + + RedeliveryPolicy redeliveryPolicy = connection.getRedeliveryPolicy(); + int redeliveryCounter = md.getMessage().getRedeliveryCounter(); + if (redeliveryPolicy.getMaximumRedeliveries() != RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES + && redeliveryCounter >= redeliveryPolicy.getMaximumRedeliveries()) { + // We need to NACK the messages so that they get + // sent to the + // DLQ. + // Acknowledge the last message. + MessageAck ack = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1); + ack.setFirstMessageId(md.getMessage().getMessageId()); + ack.setPoisonCause(new Throwable("Exceeded ra redelivery policy limit:" + redeliveryPolicy)); + asyncSendPacket(ack); + + } else { + + MessageAck ack = new MessageAck(md, MessageAck.REDELIVERED_ACK_TYPE, 1); + ack.setFirstMessageId(md.getMessage().getMessageId()); + asyncSendPacket(ack); + + // Figure out how long we should wait to resend + // this message. + long redeliveryDelay = redeliveryPolicy.getInitialRedeliveryDelay(); + for (int i = 0; i < redeliveryCounter; i++) { + redeliveryDelay = redeliveryPolicy.getNextRedeliveryDelay(redeliveryDelay); } - }, redeliveryDelay); + + /* + * If we are a non blocking delivery then we need to stop the executor to avoid more + * messages being delivered, once the message is redelivered we can restart it. + * */ + if (!connection.isNonBlockingRedelivery()) { + LOG.debug("Blocking session until re-delivery..."); + executor.stop(); + } + + connection.getScheduler().executeAfterDelay(new Runnable() { + + @Override + public void run() { + /* + * wait for the first delivery to be complete, i.e. after delivery has been called. + * */ + synchronized (REDELIVERY_GUARD) { + /* + * If its non blocking then we can just dispatch in a new session. + * */ + if (connection.isNonBlockingRedelivery()) { + ((ActiveMQDispatcher) md.getConsumer()).dispatch(md); + } else { + /* + * If there has been an error thrown during afterDelivery then the + * endpoint will be marked as dead so redelivery will fail (and eventually + * the session marked as stale), in this case we can only call dispatch + * which will create a new session with a new endpoint. + * */ + if (afterDeliveryError.get()) { + ((ActiveMQDispatcher) md.getConsumer()).dispatch(md); + } else { + executor.executeFirst(md); + executor.start(); + } + } + } + } + }, redeliveryDelay); + } + md.getMessage().onMessageRolledBack(); } - md.getMessage().onMessageRolledBack(); + }); + } + + LOG.trace("{} onMessage({})", this, message.getMessageId()); + messageListener.onMessage(message); + + } catch (Throwable e) { + LOG.error("error dispatching message: ", e); + + // A problem while invoking the MessageListener does not + // in general indicate a problem with the connection to the broker, i.e. + // it will usually be sufficient to let the afterDelivery() method either + // commit or roll back in order to deal with the exception. + // However, we notify any registered client internal exception listener + // of the problem. + connection.onClientInternalException(e); + } finally { + if (ack.getTransactionId() == null) { + try { + asyncSendPacket(ack); + } catch (Throwable e) { + connection.onClientInternalException(e); } - }); + } } - LOG.trace("{} onMessage({})", this, message.getMessageId()); - messageListener.onMessage(message); - - } catch (Throwable e) { - LOG.error("error dispatching message: ", e); - // A problem while invoking the MessageListener does not - // in general indicate a problem with the connection to the broker, i.e. - // it will usually be sufficient to let the afterDelivery() method either - // commit or roll back in order to deal with the exception. - // However, we notify any registered client internal exception listener - // of the problem. - connection.onClientInternalException(e); - } finally { - if (ack.getTransactionId() == null) { + if (deliveryListener != null) { try { - asyncSendPacket(ack); - } catch (Throwable e) { - connection.onClientInternalException(e); + deliveryListener.afterDelivery(this, message); + } catch (Throwable t) { + LOG.debug("Unable to call after delivery", t); + afterDeliveryError.set(true); + throw t; } } } - - if (deliveryListener != null) { - deliveryListener.afterDelivery(this, message); - } - + /* + * this can be outside the try/catch as if an exception is thrown then this session will be marked as stale anyway. + * It also needs to be outside the redelivery guard. + * */ try { executor.waitForQueueRestart(); } catch (InterruptedException ex) { connection.onClientInternalException(ex); - } + } } } @@ -2118,7 +2158,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta @Override public String toString() { - return "ActiveMQSession {id=" + info.getSessionId() + ",started=" + started.get() + "}"; + return "ActiveMQSession {id=" + info.getSessionId() + ",started=" + started.get() + "} " + sendMutex; } public void checkMessageListener() throws JMSException { From c2310391b9feab44bfaa46e93f0e4ca90d5bf357 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Mon, 15 Jun 2015 18:37:54 -0400 Subject: [PATCH 19/52] https://issues.apache.org/jira/browse/AMQ-5845 provide server information in connection properties. --- .../activemq/transport/amqp/AmqpSupport.java | 3 ++ .../amqp/protocol/AmqpConnection.java | 28 +++++++++++++++++++ .../amqp/interop/AmqpConnectionsTest.java | 17 +++++++++++ 3 files changed, 48 insertions(+) diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java index 0d3f733253..9544e33ca9 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java @@ -54,6 +54,9 @@ public class AmqpSupport { public static final Symbol QUEUE_PREFIX = Symbol.valueOf("queue-prefix"); public static final Symbol TOPIC_PREFIX = Symbol.valueOf("topic-prefix"); public static final Symbol CONNECTION_OPEN_FAILED = Symbol.valueOf("amqp:connection-establishment-failed"); + public static final Symbol PRODUCT = Symbol.valueOf("product"); + public static final Symbol VERSION = Symbol.valueOf("version"); + public static final Symbol PLATFORM = Symbol.valueOf("platform"); // Symbols used in configuration of newly opened links. public static final Symbol COPY = Symbol.getSymbol("copy"); diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java index 962d48f24c..577fcad2bc 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java @@ -20,13 +20,19 @@ import static org.apache.activemq.transport.amqp.AmqpSupport.ANONYMOUS_RELAY; import static org.apache.activemq.transport.amqp.AmqpSupport.CONNECTION_OPEN_FAILED; import static org.apache.activemq.transport.amqp.AmqpSupport.CONTAINER_ID; import static org.apache.activemq.transport.amqp.AmqpSupport.INVALID_FIELD; +import static org.apache.activemq.transport.amqp.AmqpSupport.PLATFORM; +import static org.apache.activemq.transport.amqp.AmqpSupport.PRODUCT; import static org.apache.activemq.transport.amqp.AmqpSupport.QUEUE_PREFIX; import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_QUEUE_CAPABILITY; import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_TOPIC_CAPABILITY; import static org.apache.activemq.transport.amqp.AmqpSupport.TOPIC_PREFIX; +import static org.apache.activemq.transport.amqp.AmqpSupport.VERSION; import static org.apache.activemq.transport.amqp.AmqpSupport.contains; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.util.Date; import java.util.HashMap; @@ -102,6 +108,25 @@ public class AmqpConnection implements AmqpProtocolConverter { private static final Logger TRACE_FRAMES = AmqpTransportFilter.TRACE_FRAMES; private static final Logger LOG = LoggerFactory.getLogger(AmqpConnection.class); private static final int CHANNEL_MAX = 32767; + private static final String BROKER_VERSION; + private static final String BROKER_PLATFORM; + + static { + String javaVersion = System.getProperty("java.version"); + + BROKER_PLATFORM = "Java/" + (javaVersion == null ? "unknown" : javaVersion); + + InputStream in = null; + String version = "5.12.0"; + if ((in = AmqpConnection.class.getResourceAsStream("/org/apache/activemq/version.txt")) != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + try { + version = reader.readLine(); + } catch(Exception e) { + } + } + BROKER_VERSION = version; + } private final Transport protonTransport = Proton.transport(); private final Connection protonConnection = Proton.connection(); @@ -170,6 +195,9 @@ public class AmqpConnection implements AmqpProtocolConverter { properties.put(QUEUE_PREFIX, "queue://"); properties.put(TOPIC_PREFIX, "topic://"); + properties.put(PRODUCT, "ActiveMQ"); + properties.put(VERSION, BROKER_VERSION); + properties.put(PLATFORM, BROKER_PLATFORM); return properties; } diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java index 783db65a56..69b45d5ce9 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java @@ -17,6 +17,9 @@ package org.apache.activemq.transport.amqp.interop; import static org.apache.activemq.transport.amqp.AmqpSupport.CONNECTION_OPEN_FAILED; +import static org.apache.activemq.transport.amqp.AmqpSupport.PLATFORM; +import static org.apache.activemq.transport.amqp.AmqpSupport.PRODUCT; +import static org.apache.activemq.transport.amqp.AmqpSupport.VERSION; import static org.apache.activemq.transport.amqp.AmqpSupport.contains; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -81,6 +84,20 @@ public class AmqpConnectionsTest extends AmqpClientTestSupport { if (!properties.containsKey(TOPIC_PREFIX)) { markAsInvalid("Broker did not send a queue prefix value"); } + + if (!properties.containsKey(PRODUCT)) { + markAsInvalid("Broker did not send a queue product name value"); + } + + if (!properties.containsKey(VERSION)) { + markAsInvalid("Broker did not send a queue version value"); + } + + if (!properties.containsKey(PLATFORM)) { + markAsInvalid("Broker did not send a queue platform name value"); + } else { + LOG.info("Broker platform = {}", properties.get(PLATFORM)); + } } }); From 1b08858a3727fd35d9ee072a97c32f0c1270244c Mon Sep 17 00:00:00 2001 From: gtully Date: Tue, 16 Jun 2015 11:36:55 +0100 Subject: [PATCH 20/52] reduce test duration - v.slow for 60k messages of size 30k -resuce to ~30s b/c it was excceeding 10mins - large linear work load not great for leveldb --- .../src/test/java/org/apache/activemq/bugs/AMQ4677Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java index fd80690f07..41bf51ca81 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java @@ -95,8 +95,8 @@ public class AMQ4677Test { assertNotNull(levelDBView); levelDBView.compact(); - final int SIZE = 6 * 1024 * 5; - final int MSG_COUNT = 60000; + final int SIZE = 10 * 1024; + final int MSG_COUNT = 30000; // very slow consuming 60k messages of size 30k final CountDownLatch done = new CountDownLatch(MSG_COUNT); byte buffer[] = new byte[SIZE]; From 1787edaf3e0d44bbce36b0cc22644cfe6f1e661f Mon Sep 17 00:00:00 2001 From: gtully Date: Tue, 16 Jun 2015 15:03:04 +0100 Subject: [PATCH 21/52] https://issues.apache.org/jira/browse/AMQ-5724 - fix up mbean object name property clashes and attribute selection. add --invoke flag to invoke simple mbean operations with void or string params, Additional test that verifies help suggestions --- .../console/command/QueryCommand.java | 113 +++++++++-- .../activemq/console/util/JmxMBeansUtil.java | 6 +- .../activemq/console/QueryCommandTest.java | 183 ++++++++++++++++++ 3 files changed, 288 insertions(+), 14 deletions(-) create mode 100644 activemq-console/src/test/java/org/apache/activemq/console/QueryCommandTest.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java index bdb6b886cf..0a5ee17684 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.console.command; +import javax.management.ObjectName; import org.apache.activemq.console.util.JmxMBeansUtil; import java.util.*; @@ -25,12 +26,12 @@ public class QueryCommand extends AbstractJmxCommand { private static final Properties PREDEFINED_OBJNAME_QUERY = new Properties(); static { - PREDEFINED_OBJNAME_QUERY.setProperty("Broker", "type=Broker,brokerName=%1"); - PREDEFINED_OBJNAME_QUERY.setProperty("Connection", "type=Broker,connector=clientConnectors,connectionName=%1,*"); - PREDEFINED_OBJNAME_QUERY.setProperty("Connector", "type=Broker,brokerName=*,connector=clientConnectors,connectorName=%1"); - PREDEFINED_OBJNAME_QUERY.setProperty("NetworkConnector", "type=Broker,brokerName=%1,connector=networkConnectors,networkConnectorName=*"); - PREDEFINED_OBJNAME_QUERY.setProperty("Queue", "type=Broker,brokerName=*,destinationType=Queue,destinationName=%1"); - PREDEFINED_OBJNAME_QUERY.setProperty("Topic", "type=Broker,brokerName=*,destinationType=Topic,destinationName=%1,*"); + PREDEFINED_OBJNAME_QUERY.setProperty("Broker", "brokerName=%1"); + PREDEFINED_OBJNAME_QUERY.setProperty("Connection", "connector=clientConnectors,connectionViewType=*,connectionName=%1,*"); + PREDEFINED_OBJNAME_QUERY.setProperty("Connector", "connector=clientConnectors,connectorName=%1"); + PREDEFINED_OBJNAME_QUERY.setProperty("NetworkConnector", "connector=networkConnectors,networkConnectorName=%1"); + PREDEFINED_OBJNAME_QUERY.setProperty("Queue", "destinationType=Queue,destinationName=%1"); + PREDEFINED_OBJNAME_QUERY.setProperty("Topic", "destinationType=Topic,destinationName=%1"); }; protected String[] helpFile = new String[] { @@ -48,6 +49,7 @@ public class QueryCommand extends AbstractJmxCommand { " similar to the JMX object name format.", " --view ,,... Select the specific attribute of the object to view.", " By default all attributes will be displayed.", + " --invoke Specify the operation to invoke on matching objects", " --jmxurl Set the JMX URL to connect to.", " --pid Set the pid to connect to (only on Sun JVM).", " --jmxuser Set the JMX user used for authenticating.", @@ -79,18 +81,23 @@ public class QueryCommand extends AbstractJmxCommand { " - Print all attributes of all topics except those that has a name that begins", " with \"ActiveMQ.Advisory\".", "", - " query --objname Type=*Connect*,BrokerName=local* -xQNetworkConnector=*", + " query --objname type=Broker,brokerName=*,connector=clientConnectors,connectorName=* -xQNetworkConnector=*", " - Print all attributes of all connectors, connections excluding network connectors", " that belongs to the broker that begins with local.", "", " query -QQueue=* -xQQueue=????", " - Print all attributes of all queues except those that are 4 letters long.", "", + " query -QQueue=* --invoke pause", + " - Pause all queues.", + "", + }; private final List queryAddObjects = new ArrayList(10); private final List querySubObjects = new ArrayList(10); private final Set queryViews = new LinkedHashSet(); + private final List opAndParams = new ArrayList(10); @Override public String getName() { @@ -111,21 +118,55 @@ public class QueryCommand extends AbstractJmxCommand { protected void runTask(List tokens) throws Exception { try { // Query for the mbeans to add - Map addMBeans = JmxMBeansUtil.queryMBeansAsMap(createJmxConnection(), queryAddObjects, queryViews); + Map addMBeans = JmxMBeansUtil.queryMBeansAsMap(createJmxConnection(), queryAddObjects, queryViews); // Query for the mbeans to sub if (querySubObjects.size() > 0) { - Map subMBeans = JmxMBeansUtil.queryMBeansAsMap(createJmxConnection(), querySubObjects, queryViews); + Map subMBeans = JmxMBeansUtil.queryMBeansAsMap(createJmxConnection(), querySubObjects, queryViews); addMBeans.keySet().removeAll(subMBeans.keySet()); } - context.printMBean(JmxMBeansUtil.filterMBeansView(new ArrayList(addMBeans.values()), queryViews)); + + if (opAndParams.isEmpty()) { + context.printMBean(JmxMBeansUtil.filterMBeansView(new ArrayList(addMBeans.values()), queryViews)); + } else { + context.print(doInvoke(addMBeans.keySet(), opAndParams)); + } } catch (Exception e) { context.printException(new RuntimeException("Failed to execute query task. Reason: " + e)); throw new Exception(e); } } + private Collection doInvoke(Set mBeans, List opAndParams) throws Exception { + LinkedList results = new LinkedList<>(); + for (Object objectName : mBeans) { + Object result = createJmxConnection().invoke((ObjectName) objectName, opAndParams.get(0), + params(opAndParams), stringSignature(opAndParams)); + results.add("[" + objectName + "]." + opAndParams.get(0) + " = " + result); + } + return results; + } + + private Object[] params(List opAndParams) { + if (opAndParams.size() > 1) { + return opAndParams.subList(1, opAndParams.size()).toArray(); + } else { + return null; + } + } + + private String[] stringSignature(List opAndParams) { + if (opAndParams.size() > 1) { + String[] sig = new String[opAndParams.size() - 1]; + Arrays.fill(sig, String.class.getName()); + return sig; + } else { + return null; + } + } + + /** - * Handle the -Q, -xQ, --objname, --xobjname, --view options. + * Handle the -Q, -xQ, --objname, --xobjname, --view --invoke options. * * @param token - option token to handle * @param tokens - succeeding command arguments @@ -153,6 +194,7 @@ public class QueryCommand extends AbstractJmxCommand { while (queryTokens.hasMoreTokens()) { queryAddObjects.add(queryTokens.nextToken()); } + normaliseObjectName(queryAddObjects); } else if (token.startsWith("-xQ")) { // If token is a substractive predefined query define option String key = token.substring(3); @@ -174,6 +216,7 @@ public class QueryCommand extends AbstractJmxCommand { while (queryTokens.hasMoreTokens()) { querySubObjects.add(queryTokens.nextToken()); } + normaliseObjectName(querySubObjects); } else if (token.startsWith("--objname")) { // If token is an additive object name query option @@ -216,12 +259,60 @@ public class QueryCommand extends AbstractJmxCommand { while (viewTokens.hasMoreElements()) { queryViews.add(viewTokens.nextElement()); } + } else if (token.startsWith("--invoke")) { + + if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) { + context.printException(new IllegalArgumentException("operation to invoke is not specified")); + return; + } + + // add op and params + Enumeration viewTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER); + while (viewTokens.hasMoreElements()) { + opAndParams.add((String)viewTokens.nextElement()); + } + } else { // Let super class handle unknown option super.handleOption(token, tokens); } } + private void normaliseObjectName(List queryAddObjects) { + ensurePresent(queryAddObjects, "type", "Broker"); + ensurePresent(queryAddObjects, "brokerName", "*"); + + // -QQueue && -QTopic + ensureUnique(queryAddObjects, "destinationType", "?????"); + ensureUnique(queryAddObjects, "destinationName", "*"); + } + + private void ensurePresent(List queryAddObjects, String id, String wildcard) { + List matches = findMatchingKeys(queryAddObjects, id); + if (matches.size() == 0) { + queryAddObjects.add(id + "=" + wildcard); + } + } + + private void ensureUnique(List queryAddObjects, String id, String wildcard) { + List matches = findMatchingKeys(queryAddObjects, id); + if (matches.size() > 1) { + queryAddObjects.removeAll(matches); + queryAddObjects.add(id + "=" + wildcard); + } + } + + private List findMatchingKeys(List queryAddObjects, String id) { + List matches = new LinkedList<>(); + for (String prop : queryAddObjects) { + String[] keyValue = prop.split("="); + if (keyValue.length == 2 && keyValue[0].equals(id)) { + matches.add(prop); + } + } + return matches; + } + /** * Print the help messages for the browse command */ diff --git a/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java b/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java index baa40be892..24fe46b2a9 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java @@ -57,12 +57,12 @@ public final class JmxMBeansUtil { } } - public static Map queryMBeansAsMap(MBeanServerConnection jmxConnection, List queryList, Set attributes) throws Exception { - Map answer = new HashMap(); + public static Map queryMBeansAsMap(MBeanServerConnection jmxConnection, List queryList, Set attributes) throws Exception { + Map answer = new HashMap(); List mbeans = queryMBeans(jmxConnection, queryList, attributes); for (AttributeList mbean : mbeans) { for(Attribute attr: mbean.asList()) { - if (attr.getName().equals("Name")) { + if (attr.getName().equals(MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE)) { answer.put(attr.getValue(), mbean); } } diff --git a/activemq-console/src/test/java/org/apache/activemq/console/QueryCommandTest.java b/activemq-console/src/test/java/org/apache/activemq/console/QueryCommandTest.java new file mode 100644 index 0000000000..b6a154ee47 --- /dev/null +++ b/activemq-console/src/test/java/org/apache/activemq/console/QueryCommandTest.java @@ -0,0 +1,183 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.console; + +import java.io.ByteArrayOutputStream; +import java.util.Arrays; +import java.util.LinkedList; +import javax.jms.Connection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.console.command.QueryCommand; +import org.apache.activemq.console.formatter.CommandShellOutputFormatter; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.LoggerFactory; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class QueryCommandTest { + private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(QueryCommandTest.class); + + final String CONNECTOR_NAME="tcp-openWire"; + final String CLIENT_ID="some-id"; + + BrokerService brokerService; + + + @Before + public void createBroker() throws Exception { + brokerService = new BrokerService(); + brokerService.getManagementContext().setCreateConnector(false); + brokerService.setPersistent(false); + brokerService.setDestinations(new ActiveMQDestination[]{new ActiveMQQueue("Q1"), new ActiveMQQueue("Q2"), new ActiveMQTopic("T1")}); + brokerService.addConnector("tcp://0.0.0.0:0").setName(CONNECTOR_NAME); + brokerService.start(); + } + + @After + public void stopBroker() throws Exception { + if (brokerService != null) { + brokerService.stop(); + } + } + + @Test + public void tryQuery() throws Exception { + + String result = executeQuery("-QQueue=* --view destinationName,EnqueueCount,DequeueCount"); + assertTrue("Output valid", result.contains("Q1")); + assertTrue("Output valid", result.contains("Q2")); + assertFalse("Output valid", result.contains("T1")); + + result = executeQuery("-QQueue=Q2 --view destinationName,QueueSize"); + assertTrue("size present", result.contains("QueueSize")); + assertTrue("Output valid", result.contains("Q2")); + assertFalse("Output valid", result.contains("Q1")); + assertFalse("Output valid", result.contains("T1")); + + result = executeQuery("-QQueue=* -xQQueue=Q1 --view destinationName,QueueSize"); + assertTrue("size present", result.contains("QueueSize")); + assertTrue("q2", result.contains("Q2")); + assertFalse("!q1: " + result, result.contains("Q1")); + assertFalse("!t1", result.contains("T1")); + + result = executeQuery("-QTopic=* -QQueue=* --view destinationName"); + assertTrue("got Q1", result.contains("Q1")); + assertTrue("got Q2", result.contains("Q2")); + assertTrue("got T1", result.contains("T1")); + + result = executeQuery("-QQueue=*"); + assertTrue("got Q1", result.contains("Q1")); + assertTrue("got Q2", result.contains("Q2")); + assertFalse("!T1", result.contains("T1")); + + result = executeQuery("-QBroker=*"); + assertTrue("got localhost", result.contains("localhost")); + + result = executeQuery("--view destinationName"); + // all mbeans with a destinationName attribute + assertTrue("got Q1", result.contains("Q1")); + assertTrue("got Q2", result.contains("Q2")); + assertTrue("got T1", result.contains("T1")); + + result = executeQuery("--objname type=Broker,brokerName=*,destinationType=Queue,destinationName=*"); + assertTrue("got Q1", result.contains("Q1")); + assertTrue("got Q2", result.contains("Q2")); + assertFalse("!T1", result.contains("T1")); + + result = executeQuery("--objname type=Broker,brokerName=*,destinationType=*,destinationName=* --xobjname type=Broker,brokerName=*,destinationType=Queue,destinationName=Q1"); + assertFalse("!Q1", result.contains("Q1")); + assertTrue("got Q2", result.contains("Q2")); + assertTrue("T1", result.contains("T1")); + + } + + @Test + public void testConnection() throws Exception { + + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectURI()); + Connection connection = connectionFactory.createConnection(); + connection.setClientID(CLIENT_ID); + connection.start(); + + String result = executeQuery("-QConnection=* --view ClientId"); + assertTrue("got client id", result.contains(CLIENT_ID)); + + result = executeQuery("--objname type=Broker,brokerName=*,connector=clientConnectors,connectorName=* -xQNetworkConnector=*"); + assertTrue("got named", result.contains(CONNECTOR_NAME)); + + result = executeQuery("-QConnector=*"); + assertTrue("got named", result.contains(CONNECTOR_NAME)); + } + + + @Test + public void testInvoke() throws Exception { + + String result = executeQuery("-QQueue=Q* --view Paused"); + assertTrue("got pause status", result.contains("Paused = false")); + + result = executeQuery("-QQueue=* --invoke pause"); + LOG.info("result of invoke: " + result); + assertTrue("invoked", result.contains("Q1")); + assertTrue("invoked", result.contains("Q2")); + + result = executeQuery("-QQueue=Q2 --view Paused"); + assertTrue("got pause status", result.contains("Paused = true")); + + result = executeQuery("-QQueue=Q2 --invoke resume"); + LOG.info("result of invoke: " + result); + assertTrue("invoked", result.contains("Q2")); + + result = executeQuery("-QQueue=Q2 --view Paused"); + assertTrue("pause status", result.contains("Paused = false")); + + result = executeQuery("-QQueue=Q1 --view Paused"); + assertTrue("pause status", result.contains("Paused = true")); + + // op with string param + result = executeQuery("-QQueue=Q2 --invoke sendTextMessage,hi"); + LOG.info("result of invoke: " + result); + assertTrue("invoked", result.contains("Q2")); + + result = executeQuery("-QQueue=Q2 --view EnqueueCount"); + assertTrue("enqueueCount", result.contains("EnqueueCount = 1")); + } + + private String executeQuery(String query) throws Exception { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024); + CommandContext context = new CommandContext(); + context.setFormatter(new CommandShellOutputFormatter(byteArrayOutputStream)); + + QueryCommand queryCommand = new QueryCommand(); + queryCommand.setJmxUseLocal(true); + queryCommand.setCommandContext(context); + + LinkedList args = new LinkedList<>(); + args.addAll(Arrays.asList(query.split(" "))); + queryCommand.execute(args); + + return byteArrayOutputStream.toString(); + } +} From ffef4dc5fa68cd0e02f4850582fb09db381394da Mon Sep 17 00:00:00 2001 From: gtully Date: Tue, 16 Jun 2015 15:54:11 +0100 Subject: [PATCH 22/52] https://issues.apache.org/jira/browse/AMQ-5844 - patch and test applied with thanks to Ganesh Murthy - ganeshmurthy --- .../transport/failover/FailoverTransport.java | 9 + .../org/apache/activemq/bugs/AMQ5844Test.java | 216 ++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5844Test.java diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java index 95c5d21832..0bccac0554 100755 --- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java +++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java @@ -40,11 +40,13 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.activemq.broker.SslContext; import org.apache.activemq.command.Command; import org.apache.activemq.command.ConnectionControl; +import org.apache.activemq.command.ConsumerControl; import org.apache.activemq.command.ConnectionId; import org.apache.activemq.command.MessageDispatch; import org.apache.activemq.command.MessagePull; import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.Response; + import org.apache.activemq.state.ConnectionStateTracker; import org.apache.activemq.state.Tracked; import org.apache.activemq.thread.Task; @@ -200,6 +202,13 @@ public class FailoverTransport implements CompositeTransport { if (command.isConnectionControl()) { handleConnectionControl((ConnectionControl) command); } + else if (command.isConsumerControl()) { + ConsumerControl consumerControl = (ConsumerControl)command; + if (consumerControl.isClose()) { + stateTracker.processRemoveConsumer(consumerControl.getConsumerId(), RemoveInfo.LAST_DELIVERED_UNKNOWN); + } + + } if (transportListener != null) { transportListener.onCommand(command); } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5844Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5844Test.java new file mode 100644 index 0000000000..64851aecab --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5844Test.java @@ -0,0 +1,216 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.bugs; + +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.broker.TransportConnector; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.BeforeClass; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.log4j.Appender; +import org.apache.log4j.spi.LoggingEvent; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.transport.failover.FailoverTransport; +import org.apache.activemq.util.DefaultIOExceptionHandler; +import org.apache.activemq.util.DefaultTestAppender; +import org.apache.activemq.util.Wait; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.TransactionRolledBackException; +import java.io.IOException; + +/** + * The FailoverTransport maintains state is the ConnectionStateTracker object. Aborted slow consumers must be removed + * from this state tracker so that the FailoverTransport does not re-register the aborted slow consumers. + */ +public class AMQ5844Test { + + static final Logger LOG = LoggerFactory.getLogger(AMQ5844Test.class); + + protected BrokerService broker; + + protected long checkPeriod = 2 * 1000; + protected long maxSlowDuration = 4 * 1000; + + private String uri; + + private final static String QUEUE_NAME = "TEST.QUEUE"; + + static boolean abortingSlowConsumer = false; + static boolean successfullyReconnected = false; + + static final Appender appender = new DefaultTestAppender() { + @Override + public void doAppend(LoggingEvent event) { + if(event.getMessage().toString().contains("aborting slow consumer")) { + abortingSlowConsumer = true; + } + + if(event.getMessage().toString().contains("Successfully reconnected to")) { + successfullyReconnected = true; + } + } + }; + + @BeforeClass + public static void setUp() throws Exception { + org.apache.log4j.Logger.getRootLogger().addAppender(appender); + } + + + @Before + /** + * Sets a AbortSlowConsumerStrategy policy entry on the broker and starts the broker. + */ + public void createMaster() throws Exception{ + broker = new BrokerService(); + broker.setDeleteAllMessagesOnStartup(true); + TransportConnector transportConnector = broker.addConnector("tcp://0.0.0.0:0"); + + DefaultIOExceptionHandler defaultIOExceptionHandler = new DefaultIOExceptionHandler(); + broker.setIoExceptionHandler(defaultIOExceptionHandler); + broker.setBrokerName("Main"); + + PolicyEntry policy = new PolicyEntry(); + AbortSlowConsumerStrategy abortSlowConsumerStrategy = new AbortSlowConsumerStrategy(); + abortSlowConsumerStrategy.setAbortConnection(false); + //time in milliseconds between checks for slow subscriptions + abortSlowConsumerStrategy.setCheckPeriod(checkPeriod); + //time in milliseconds that a sub can remain slow before triggering an abort + abortSlowConsumerStrategy.setMaxSlowDuration(maxSlowDuration); + + policy.setSlowConsumerStrategy(abortSlowConsumerStrategy); + policy.setQueuePrefetch(0); + PolicyMap pMap = new PolicyMap(); + pMap.setDefaultEntry(policy); + broker.setDestinationPolicy(pMap); + + broker.start(); + uri = transportConnector.getPublishableConnectString(); + } + + @After + public void stopBroker() throws Exception { + if (broker != null) { + broker.stop(); + broker.waitUntilStopped(); + } + org.apache.log4j.Logger.getRootLogger().removeAppender(appender); + } + + @Test + public void testRecreateAbortedConsumer() throws Exception { + String failoverTransportURL = "failover:(" + uri + ")"; + + ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory(failoverTransportURL); + amq.setWatchTopicAdvisories(false); + + Connection jmsConnection = amq.createConnection(); + + ActiveMQConnection connection = (ActiveMQConnection) jmsConnection; + + connection.start(); + + // Create a Session that is transacted + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + + //Create the destination Queue + Destination destination = session.createQueue(QUEUE_NAME); + + //Create a MessageProducer from the Session to the Queue + MessageProducer producer = session.createProducer(destination); + + // Create message, send and close producer + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Plain Text Message"); + + String text = stringBuilder.toString(); + TextMessage message = session.createTextMessage(text); + + //Send 2 non-persistent text messages + producer.send(message, DeliveryMode.NON_PERSISTENT, 1, 0); + producer.send(message, DeliveryMode.NON_PERSISTENT, 1, 0); + //Commit the session so the messages get delivered to the broker + session.commit(); + //close the producer and get it out of the way + producer.close(); + + //Start consuming the messages. + ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(destination); + Message mess = consumer.receive(); + //First message received successfully. + assertNotNull(mess); + + //The AbortSlowConsumerStrategy kicks in here and sends a message down to the client to close itself. + //The client does not close because it is in the middle of the transaction. Meanwhile the FailoverTransport + //detects the close command and removes the consumer from its state. + + assertTrue("The browser aborts the slow consumer", Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return abortingSlowConsumer; + } + }, 10 * 1000)); + + //We intentionally fail the transport just to make sure that the slow consumer that was aborted is not + //re-registered by the FailoverTransport + FailoverTransport failoverTransport = connection.getTransport().narrow(FailoverTransport.class); + failoverTransport.handleTransportFailure(new IOException()); + + assertTrue("The broker aborts the slow consumer", Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return successfullyReconnected; + } + }, 4 * 1000)); + + try { + mess = consumer.receive(2 * 1000); + //This message must be null because the slow consumer has already been deleted on the broker side. + assertNull(mess); + session.commit(); + fail("Expect the commit to fail and a rollback to happen"); + } + catch (TransactionRolledBackException expected) { + assertTrue(expected.getMessage().contains("rolling back transaction")); + } + + connection.close(); + } +} From 540d8c70794228c9f52667e44a3c48ae64e4e5c9 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 16 Jun 2015 12:35:17 -0400 Subject: [PATCH 23/52] Turn off expired message processing during this test, the browse for expired message can trip the limits that this test expects to end up with which is not what is being tested here. --- .../apache/activemq/usecases/MemoryLimitTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java index e3641be327..3e3dcff893 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java @@ -17,15 +17,17 @@ package org.apache.activemq.usecases; import java.util.Arrays; -import javax.jms.*; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; -import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.jmx.QueueView; import org.apache.activemq.broker.jmx.QueueViewMBean; import org.apache.activemq.broker.region.Destination; import org.apache.activemq.broker.region.policy.PolicyEntry; @@ -65,6 +67,7 @@ public class MemoryLimitTest extends TestSupport { PolicyMap policyMap = new PolicyMap(); PolicyEntry policyEntry = new PolicyEntry(); policyEntry.setProducerFlowControl(false); + policyEntry.setExpireMessagesPeriod(0); policyMap.put(new ActiveMQQueue(">"), policyEntry); broker.setDestinationPolicy(policyMap); From edacc2a8404d1a460fb08edd979285961802c0ac Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Mon, 15 Jun 2015 17:38:49 +0000 Subject: [PATCH 24/52] https://issues.apache.org/jira/browse/AMQ-5843 Adding a new property on PolicyEntry called includeBodyForAdvisory which will include the original message body when sending advisory messages that include the original message, instead of clearing it out. This is turned off by default. --- .../activemq/advisory/AdvisoryBroker.java | 27 ++++++-- .../broker/region/BaseDestination.java | 9 +++ .../broker/region/policy/PolicyEntry.java | 22 +++++++ .../activemq/advisory/AdvisoryTests.java | 63 ++++++++++++++++++- 4 files changed, 115 insertions(+), 6 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java index 39cd2fe303..7a6915d77e 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java +++ b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java @@ -31,6 +31,7 @@ import org.apache.activemq.broker.BrokerFilter; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ProducerBrokerExchange; +import org.apache.activemq.broker.region.BaseDestination; import org.apache.activemq.broker.region.Destination; import org.apache.activemq.broker.region.DurableTopicSubscription; import org.apache.activemq.broker.region.MessageReference; @@ -350,7 +351,9 @@ public class AdvisoryBroker extends BrokerFilter { if (!messageReference.isAdvisory()) { ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(messageReference.getMessage().getDestination()); Message payload = messageReference.getMessage().copy(); - payload.clearBody(); + if (!isIncludeBodyForAdvisory(messageReference.getMessage().getDestination())) { + payload.clearBody(); + } ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString()); fireAdvisory(context, topic, payload, null, advisoryMessage); @@ -367,7 +370,9 @@ public class AdvisoryBroker extends BrokerFilter { if (!messageReference.isAdvisory()) { ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(messageReference.getMessage().getDestination()); Message payload = messageReference.getMessage().copy(); - payload.clearBody(); + if (!isIncludeBodyForAdvisory(messageReference.getMessage().getDestination())) { + payload.clearBody(); + } ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString()); ActiveMQDestination destination = payload.getDestination(); @@ -388,7 +393,9 @@ public class AdvisoryBroker extends BrokerFilter { if (!messageReference.isAdvisory()) { ActiveMQTopic topic = AdvisorySupport.getMessageDeliveredAdvisoryTopic(messageReference.getMessage().getDestination()); Message payload = messageReference.getMessage().copy(); - payload.clearBody(); + if (!isIncludeBodyForAdvisory(messageReference.getMessage().getDestination())) { + payload.clearBody(); + } ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString()); ActiveMQDestination destination = payload.getDestination(); @@ -409,7 +416,9 @@ public class AdvisoryBroker extends BrokerFilter { if (!messageReference.isAdvisory()) { ActiveMQTopic topic = AdvisorySupport.getMessageDiscardedAdvisoryTopic(messageReference.getMessage().getDestination()); Message payload = messageReference.getMessage().copy(); - payload.clearBody(); + if (!isIncludeBodyForAdvisory(messageReference.getMessage().getDestination())) { + payload.clearBody(); + } ActiveMQMessage advisoryMessage = new ActiveMQMessage(); if (sub instanceof TopicSubscription) { advisoryMessage.setIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT, ((TopicSubscription) sub).discarded()); @@ -498,7 +507,9 @@ public class AdvisoryBroker extends BrokerFilter { if (!messageReference.isAdvisory()) { ActiveMQTopic topic = AdvisorySupport.getMessageDLQdAdvisoryTopic(messageReference.getMessage().getDestination()); Message payload = messageReference.getMessage().copy(); - payload.clearBody(); + if (!isIncludeBodyForAdvisory(messageReference.getMessage().getDestination())) { + payload.clearBody(); + } fireAdvisory(context, topic, payload); } } catch (Exception e) { @@ -551,6 +562,12 @@ public class AdvisoryBroker extends BrokerFilter { } } + protected boolean isIncludeBodyForAdvisory(ActiveMQDestination activemqDestination) { + Destination destination = next.getDestinationMap(activemqDestination).get(activemqDestination); + return (destination instanceof BaseDestination && + ((BaseDestination) destination).isIncludeBodyForAdvisory()) ? true : false; + } + private void handleFireFailure(String message, Throwable cause) { LOG.warn("Failed to fire {} advisory, reason: {}", message, cause); LOG.debug("{} detail: {}", message, cause); diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java index 5d51b24300..da6ca4182e 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java @@ -84,6 +84,7 @@ public abstract class BaseDestination implements Destination { private boolean advisoryForDelivery; private boolean advisoryForConsumed; private boolean sendAdvisoryIfNoConsumers; + private boolean includeBodyForAdvisory; protected final DestinationStatistics destinationStatistics = new DestinationStatistics(); protected final BrokerService brokerService; protected final Broker regionBroker; @@ -466,6 +467,14 @@ public abstract class BaseDestination implements Destination { this.sendAdvisoryIfNoConsumers = sendAdvisoryIfNoConsumers; } + public boolean isIncludeBodyForAdvisory() { + return includeBodyForAdvisory; + } + + public void setIncludeBodyForAdvisory(boolean includeBodyForAdvisory) { + this.includeBodyForAdvisory = includeBodyForAdvisory; + } + /** * @return the dead letter strategy */ diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java index 26cfa6b156..2e8c2a7f9e 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java @@ -81,6 +81,7 @@ public class PolicyEntry extends DestinationMapEntry { private boolean advisoryWhenFull; private boolean advisoryForDelivery; private boolean advisoryForConsumed; + private boolean includeBodyForAdvisory; private long expireMessagesPeriod = BaseDestination.EXPIRE_MESSAGE_PERIOD; private int maxExpirePageSize = BaseDestination.MAX_BROWSE_PAGE_SIZE; private int queuePrefetch=ActiveMQPrefetchPolicy.DEFAULT_QUEUE_PREFETCH; @@ -200,6 +201,7 @@ public class PolicyEntry extends DestinationMapEntry { destination.setAdvisoryForSlowConsumers(isAdvisoryForSlowConsumers()); destination.setAdvisoryForFastProducers(isAdvisoryForFastProducers()); destination.setAdvisoryWhenFull(isAdvisoryWhenFull()); + destination.setIncludeBodyForAdvisory(isIncludeBodyForAdvisory()); destination.setSendAdvisoryIfNoConsumers(isSendAdvisoryIfNoConsumers()); } @@ -740,6 +742,26 @@ public class PolicyEntry extends DestinationMapEntry { this.advisoryForFastProducers = advisoryForFastProducers; } + /** + * Returns true if the original message body should be included when applicable + * for advisory messages + * + * @return + */ + public boolean isIncludeBodyForAdvisory() { + return includeBodyForAdvisory; + } + + /** + * Sets if the original message body should be included when applicable + * for advisory messages + * + * @param includeBodyForAdvisory + */ + public void setIncludeBodyForAdvisory(boolean includeBodyForAdvisory) { + this.includeBodyForAdvisory = includeBodyForAdvisory; + } + public void setMaxExpirePageSize(int maxExpirePageSize) { this.maxExpirePageSize = maxExpirePageSize; } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java index 1ad1ef4070..ce072aa5fd 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java @@ -20,6 +20,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import java.util.Arrays; +import java.util.Collection; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -44,10 +47,14 @@ import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; /** * Test for advisory messages sent under the right circumstances. */ +@RunWith(Parameterized.class) public class AdvisoryTests { protected static final int MESSAGE_COUNT = 2000; @@ -55,9 +62,25 @@ public class AdvisoryTests { protected Connection connection; protected String bindAddress = ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL; protected int topicCount; - + protected final boolean includeBodyForAdvisory; protected final int EXPIRE_MESSAGE_PERIOD = 10000; + + @Parameters + public static Collection data() { + return Arrays.asList(new Object[][] { + // Include the full body of the message + {true}, + // Don't include the full body of the message + {false} + }); + } + + public AdvisoryTests(boolean includeBodyForAdvisory) { + super(); + this.includeBodyForAdvisory = includeBodyForAdvisory; + } + @Test(timeout = 60000) public void testNoSlowConsumerAdvisory() throws Exception { Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -122,6 +145,11 @@ public class AdvisoryTests { Message msg = advisoryConsumer.receive(1000); assertNotNull(msg); + ActiveMQMessage message = (ActiveMQMessage) msg; + ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + //Add assertion to make sure body is included for advisory topics + //when includeBodyForAdvisory is true + assertIncludeBodyForAdvisory(payload); } @Test(timeout = 60000) @@ -149,6 +177,9 @@ public class AdvisoryTests { ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); String originalId = payload.getJMSMessageID(); assertEquals(originalId, id); + //Add assertion to make sure body is included for advisory topics + //when includeBodyForAdvisory is true + assertIncludeBodyForAdvisory(payload); } @Test(timeout = 60000) @@ -171,6 +202,11 @@ public class AdvisoryTests { Message msg = advisoryConsumer.receive(EXPIRE_MESSAGE_PERIOD); assertNotNull(msg); + ActiveMQMessage message = (ActiveMQMessage) msg; + ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + //Add assertion to make sure body is included for advisory topics + //when includeBodyForAdvisory is true + assertIncludeBodyForAdvisory(payload); } @Test(timeout = 60000) @@ -185,14 +221,24 @@ public class AdvisoryTests { for (int i = 0; i < 100; i++) { s.createConsumer(advisoryTopic); } + MessageConsumer advisoryConsumer = s.createConsumer(AdvisorySupport.getMessageDLQdAdvisoryTopic((ActiveMQDestination) topic)); MessageProducer producer = s.createProducer(topic); int count = 10; for (int i = 0; i < count; i++) { BytesMessage m = s.createBytesMessage(); + m.writeBytes(new byte[1024]); producer.send(m); } + Message msg = advisoryConsumer.receive(1000); + assertNotNull(msg); + ActiveMQMessage message = (ActiveMQMessage) msg; + ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + //Add assertion to make sure body is included for DLQ advisory topics + //when includeBodyForAdvisory is true + assertIncludeBodyForAdvisory(payload); + // we should get here without StackOverflow } @@ -211,11 +257,17 @@ public class AdvisoryTests { int count = (new ActiveMQPrefetchPolicy().getTopicPrefetch() * 2); for (int i = 0; i < count; i++) { BytesMessage m = s.createBytesMessage(); + m.writeBytes(new byte[1024]); producer.send(m); } Message msg = advisoryConsumer.receive(1000); assertNotNull(msg); + ActiveMQMessage message = (ActiveMQMessage) msg; + ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + //Add assertion to make sure body is included for advisory topics + //when includeBodyForAdvisory is true + assertIncludeBodyForAdvisory(payload); } @Before @@ -258,6 +310,7 @@ public class AdvisoryTests { policy.setAdvisoryForDiscardingMessages(true); policy.setAdvisoryForSlowConsumers(true); policy.setAdvisoryWhenFull(true); + policy.setIncludeBodyForAdvisory(includeBodyForAdvisory); policy.setProducerFlowControl(false); ConstantPendingMessageLimitStrategy strategy = new ConstantPendingMessageLimitStrategy(); strategy.setLimit(10); @@ -269,4 +322,12 @@ public class AdvisoryTests { answer.addConnector(bindAddress); answer.setDeleteAllMessagesOnStartup(true); } + + protected void assertIncludeBodyForAdvisory(ActiveMQMessage payload) { + if (includeBodyForAdvisory) { + assertNotNull(payload.getContent()); + } else { + assertNull(payload.getContent()); + } + } } From ed266835b5aabfcb05e382f3056353a72347f158 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 16 Jun 2015 16:41:18 -0400 Subject: [PATCH 25/52] https://issues.apache.org/jira/browse/AMQ-5847 Add workarounds to allow for TX work to take place in multiple sessions on the same connection. Future work needed to properly support TXN Capabilities defined in the spec and support checking of violations of expected behavior. --- .../amqp/protocol/AmqpConnection.java | 20 ++++++++ .../transport/amqp/protocol/AmqpReceiver.java | 8 +-- .../transport/amqp/protocol/AmqpSender.java | 14 ++--- .../transport/amqp/protocol/AmqpSession.java | 13 +++++ .../protocol/AmqpTransactionCoordinator.java | 51 +++++++++++-------- .../amqp/JMSClientTransactionTest.java | 32 ++++++++++++ 6 files changed, 107 insertions(+), 31 deletions(-) diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java index 577fcad2bc..c04a61f32e 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java @@ -60,11 +60,13 @@ import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.DestinationInfo; import org.apache.activemq.command.ExceptionResponse; +import org.apache.activemq.command.LocalTransactionId; import org.apache.activemq.command.MessageDispatch; import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.Response; import org.apache.activemq.command.SessionId; import org.apache.activemq.command.ShutdownInfo; +import org.apache.activemq.command.TransactionId; import org.apache.activemq.transport.InactivityIOException; import org.apache.activemq.transport.amqp.AmqpHeader; import org.apache.activemq.transport.amqp.AmqpInactivityMonitor; @@ -142,10 +144,12 @@ public class AmqpConnection implements AmqpProtocolConverter { private final ConnectionInfo connectionInfo = new ConnectionInfo(); private long nextSessionId; private long nextTempDestinationId; + private long nextTransactionId; private boolean closing; private boolean closedSocket; private AmqpAuthenticator authenticator; + private final Map transactions = new HashMap(); private final ConcurrentMap resposeHandlers = new ConcurrentHashMap(); private final ConcurrentMap subscriptionsByConsumerId = new ConcurrentHashMap(); @@ -667,6 +671,22 @@ public class AmqpConnection implements AmqpProtocolConverter { subscriptionsByConsumerId.remove(consumerId); } + void registerTransaction(TransactionId txId, AmqpTransactionCoordinator coordinator) { + transactions.put(txId, coordinator); + } + + void unregisterTransaction(TransactionId txId) { + transactions.remove(txId); + } + + AmqpTransactionCoordinator getTxCoordinator(TransactionId txId) { + return transactions.get(txId); + } + + LocalTransactionId getNextTransactionId() { + return new LocalTransactionId(getConnectionId(), ++nextTransactionId); + } + ConsumerInfo lookupSubscription(String subscriptionName) throws AmqpProtocolException { ConsumerInfo result = null; RegionBroker regionBroker; diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpReceiver.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpReceiver.java index 6e52fec282..e62ad04a7a 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpReceiver.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpReceiver.java @@ -31,6 +31,7 @@ import org.apache.activemq.command.ProducerId; import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.Response; +import org.apache.activemq.command.TransactionId; import org.apache.activemq.transport.amqp.AmqpProtocolConverter; import org.apache.activemq.transport.amqp.ResponseHandler; import org.apache.activemq.transport.amqp.message.AMQPNativeInboundTransformer; @@ -205,9 +206,10 @@ public class AmqpReceiver extends AmqpAbstractReceiver { final DeliveryState remoteState = delivery.getRemoteState(); if (remoteState != null && remoteState instanceof TransactionalState) { - TransactionalState s = (TransactionalState) remoteState; - long txid = toLong(s.getTxnId()); - message.setTransactionId(new LocalTransactionId(session.getConnection().getConnectionId(), txid)); + TransactionalState txState = (TransactionalState) remoteState; + TransactionId txId = new LocalTransactionId(session.getConnection().getConnectionId(), toLong(txState.getTxnId())); + session.enlist(txId); + message.setTransactionId(txId); } message.onSend(); diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java index 1dd99d2146..4cbf744f4c 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java @@ -34,6 +34,7 @@ import org.apache.activemq.command.MessagePull; import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.RemoveSubscriptionInfo; import org.apache.activemq.command.Response; +import org.apache.activemq.command.TransactionId; import org.apache.activemq.transport.amqp.AmqpProtocolConverter; import org.apache.activemq.transport.amqp.ResponseHandler; import org.apache.activemq.transport.amqp.message.ActiveMQJMSVendor; @@ -447,14 +448,13 @@ public class AmqpSender extends AmqpAbstractLink { DeliveryState remoteState = delivery.getRemoteState(); if (remoteState != null && remoteState instanceof TransactionalState) { - TransactionalState s = (TransactionalState) remoteState; - long txid = toLong(s.getTxnId()); - LocalTransactionId localTxId = new LocalTransactionId(session.getConnection().getConnectionId(), txid); - ack.setTransactionId(localTxId); + TransactionalState txState = (TransactionalState) remoteState; + TransactionId txId = new LocalTransactionId(session.getConnection().getConnectionId(), toLong(txState.getTxnId())); + ack.setTransactionId(txId); - // Store the message sent in this TX we might need to - // re-send on rollback - md.getMessage().setTransactionId(localTxId); + // Store the message sent in this TX we might need to re-send on rollback + session.enlist(txId); + md.getMessage().setTransactionId(txId); dispatchedInTx.addFirst(md); } diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSession.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSession.java index ca3a90fb7f..20a8b9f480 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSession.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSession.java @@ -41,6 +41,7 @@ import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.command.Response; import org.apache.activemq.command.SessionId; import org.apache.activemq.command.SessionInfo; +import org.apache.activemq.command.TransactionId; import org.apache.activemq.selector.SelectorParser; import org.apache.activemq.transport.amqp.AmqpProtocolConverter; import org.apache.activemq.transport.amqp.AmqpProtocolException; @@ -72,6 +73,7 @@ public class AmqpSession implements AmqpResource { private final Session protonSession; private final SessionId sessionId; + private boolean enlisted; private long nextProducerId = 0; private long nextConsumerId = 0; @@ -122,6 +124,8 @@ public class AmqpSession implements AmqpResource { for (AmqpSender consumer : consumers.values()) { consumer.commit(); } + + enlisted = false; } /** @@ -133,6 +137,8 @@ public class AmqpSession implements AmqpResource { for (AmqpSender consumer : consumers.values()) { consumer.rollback(); } + + enlisted = false; } /** @@ -367,6 +373,13 @@ public class AmqpSession implements AmqpResource { connection.unregisterSender(consumerId); } + public void enlist(TransactionId txId) { + if (!enlisted) { + connection.getTxCoordinator(txId).enlist(this); + enlisted = true; + } + } + //----- Configuration accessors ------------------------------------------// public AmqpConnection getConnection() { diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpTransactionCoordinator.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpTransactionCoordinator.java index 576ce2059b..40bcda5d47 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpTransactionCoordinator.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpTransactionCoordinator.java @@ -20,6 +20,8 @@ import static org.apache.activemq.transport.amqp.AmqpSupport.toBytes; import static org.apache.activemq.transport.amqp.AmqpSupport.toLong; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ConnectionId; @@ -54,7 +56,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { private static final Logger LOG = LoggerFactory.getLogger(AmqpTransactionCoordinator.class); - private long nextTransactionId; + private final Set txSessions = new HashSet(); /** * Creates a new Transaction coordinator used to manage AMQP transactions. @@ -82,7 +84,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { } final AmqpSession session = (AmqpSession) getEndpoint().getSession().getContext(); - ConnectionId connectionId = session.getConnection().getConnectionId(); + final ConnectionId connectionId = session.getConnection().getConnectionId(); final Object action = ((AmqpValue) message.getBody()).getValue(); LOG.debug("COORDINATOR received: {}, [{}]", action, deliveryBytes); @@ -92,35 +94,41 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { throw new Exception("don't know how to handle a declare /w a set GlobalId"); } - long txid = getNextTransactionId(); - TransactionInfo txinfo = new TransactionInfo(connectionId, new LocalTransactionId(connectionId, txid), TransactionInfo.BEGIN); - sendToActiveMQ(txinfo, null); - LOG.trace("started transaction {}", txid); + LocalTransactionId txId = session.getConnection().getNextTransactionId(); + TransactionInfo txInfo = new TransactionInfo(connectionId, txId, TransactionInfo.BEGIN); + session.getConnection().registerTransaction(txId, this); + sendToActiveMQ(txInfo, null); + LOG.trace("started transaction {}", txId.getValue()); Declared declared = new Declared(); - declared.setTxnId(new Binary(toBytes(txid))); + declared.setTxnId(new Binary(toBytes(txId.getValue()))); delivery.disposition(declared); delivery.settle(); } else if (action instanceof Discharge) { - Discharge discharge = (Discharge) action; - long txid = toLong(discharge.getTxnId()); - + final Discharge discharge = (Discharge) action; + final LocalTransactionId txId = new LocalTransactionId(connectionId, toLong(discharge.getTxnId())); final byte operation; + if (discharge.getFail()) { - LOG.trace("rollback transaction {}", txid); + LOG.trace("rollback transaction {}", txId.getValue()); operation = TransactionInfo.ROLLBACK; } else { - LOG.trace("commit transaction {}", txid); + LOG.trace("commit transaction {}", txId.getValue()); operation = TransactionInfo.COMMIT_ONE_PHASE; } - if (operation == TransactionInfo.ROLLBACK) { - session.rollback(); - } else { - session.commit(); + for (AmqpSession txSession : txSessions) { + if (operation == TransactionInfo.ROLLBACK) { + txSession.rollback(); + } else { + txSession.commit(); + } } - TransactionInfo txinfo = new TransactionInfo(connectionId, new LocalTransactionId(connectionId, txid), operation); + txSessions.clear(); + session.getConnection().unregisterTransaction(txId); + + TransactionInfo txinfo = new TransactionInfo(connectionId, txId, operation); sendToActiveMQ(txinfo, new ResponseHandler() { @Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { @@ -132,6 +140,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { } else { delivery.disposition(Accepted.getInstance()); } + LOG.debug("TX: {} settling {}", operation, action); delivery.settle(); session.pumpProtonToSocket(); @@ -157,10 +166,6 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { } } - private long getNextTransactionId() { - return ++nextTransactionId; - } - @Override public ActiveMQDestination getDestination() { return null; @@ -169,4 +174,8 @@ public class AmqpTransactionCoordinator extends AmqpAbstractReceiver { @Override public void setDestination(ActiveMQDestination destination) { } + + public void enlist(AmqpSession session) { + txSessions.add(session); + } } diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTransactionTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTransactionTest.java index 508638e18f..560edda9a8 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTransactionTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTransactionTest.java @@ -43,6 +43,38 @@ public class JMSClientTransactionTest extends JMSClientTestSupport { private final int MSG_COUNT = 1000; + @Test(timeout = 60000) + public void testProduceOneConsumeOneInTx() throws Exception { + connection = createConnection(); + connection.start(); + + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + Destination queue = session.createQueue(getTestName()); + MessageProducer messageProducer = session.createProducer(queue); + + messageProducer.send(session.createMessage()); + session.rollback(); + + QueueViewMBean queueView = getProxyToQueue(getTestName()); + assertEquals(0, queueView.getQueueSize()); + + messageProducer.send(session.createMessage()); + session.commit(); + + assertEquals(1, queueView.getQueueSize()); + + MessageConsumer messageConsumer = session.createConsumer(queue); + assertNotNull(messageConsumer.receive(5000)); + session.rollback(); + + assertEquals(1, queueView.getQueueSize()); + + assertNotNull(messageConsumer.receive(5000)); + session.commit(); + + assertEquals(0, queueView.getQueueSize()); + } + @Test(timeout = 60000) public void testSingleConsumedMessagePerTxCase() throws Exception { connection = createConnection(); From 471911466b1c0d4acedacd4180ed6b39531a0119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Baptiste=20Onofr=C3=A9?= Date: Wed, 17 Jun 2015 11:13:48 +0200 Subject: [PATCH 26/52] [AMQ-5770] Remove javax.servlet.resources package import allowing web console to work with Karaf 2.4.x, 3.x, and 4.x --- activemq-web-console/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/activemq-web-console/pom.xml b/activemq-web-console/pom.xml index 1f1e641e99..4bdbe51400 100755 --- a/activemq-web-console/pom.xml +++ b/activemq-web-console/pom.xml @@ -142,7 +142,6 @@ org.w3c.dom, javax.servlet;version="[2.5,4)", javax.servlet.http;version="[2.5,4)", - javax.servlet.resources;version="[2.5,4)", javax.servlet.jsp, javax.servlet.jsp.tagext, javax.servlet.jsp.el, From 6cf9a8a9a56963ebe87463c1115fcb018711d82f Mon Sep 17 00:00:00 2001 From: gtully Date: Wed, 17 Jun 2015 14:21:18 +0100 Subject: [PATCH 27/52] ci disks seem to be really slow on force, increasing timeout and decreasing load on this test --- .../java/org/apache/activemq/bugs/AMQ2149Test.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java index b2eba61366..bc80ea99bb 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java @@ -364,7 +364,7 @@ public class AMQ2149Test { verifyStats(false); } - @Test(timeout = 5 * 60 * 1000) + @Test(timeout = 10 * 60 * 1000) public void testOrderWithRestart() throws Exception { createBroker(new Configurer() { public void configure(BrokerService broker) throws Exception { @@ -387,7 +387,7 @@ public class AMQ2149Test { verifyStats(true); } - @Test(timeout = 5 * 60 * 1000) + @Test(timeout = 10 * 60 * 1000) public void testTopicOrderWithRestart() throws Exception { createBroker(new Configurer() { public void configure(BrokerService broker) throws Exception { @@ -407,18 +407,18 @@ public class AMQ2149Test { verifyStats(true); } - @Test(timeout = 5 * 60 * 1000) + @Test(timeout = 10 * 60 * 1000) public void testQueueTransactionalOrderWithRestart() throws Exception { doTestTransactionalOrderWithRestart(ActiveMQDestination.QUEUE_TYPE); } - @Test(timeout = 5 * 60 * 1000) + @Test(timeout = 10 * 60 * 1000) public void testTopicTransactionalOrderWithRestart() throws Exception { doTestTransactionalOrderWithRestart(ActiveMQDestination.TOPIC_TYPE); } public void doTestTransactionalOrderWithRestart(byte destinationType) throws Exception { - numtoSend = 10000; + numtoSend = 5000; sleepBetweenSend = 3; brokerStopPeriod = 10 * 1000; @@ -519,10 +519,10 @@ public class AMQ2149Test { threads.add(thread); } - final long expiry = System.currentTimeMillis() + 1000 * 60 * 4; + final long expiry = System.currentTimeMillis() + 1000 * 60 * 10; while(!threads.isEmpty() && exceptions.isEmpty() && System.currentTimeMillis() < expiry) { Thread sendThread = threads.firstElement(); - sendThread.join(1000*30); + sendThread.join(1000*60*10); if (!sendThread.isAlive()) { threads.remove(sendThread); } else { From 38f7857533ecd71641b8d7f0075351972469cf2c Mon Sep 17 00:00:00 2001 From: gtully Date: Wed, 17 Jun 2015 14:23:08 +0100 Subject: [PATCH 28/52] bring some more consistency to derby usage and log nested exceptions on create failure --- .../store/jdbc/DataSourceServiceSupport.java | 6 +++- .../network/NetworkBrokerDetachTest.java | 12 ++++--- .../jdbc/JDBCNetworkBrokerDetachTest.java | 32 ++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/DataSourceServiceSupport.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/DataSourceServiceSupport.java index 9790d3d8c6..cf7cb0d932 100644 --- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/DataSourceServiceSupport.java +++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/DataSourceServiceSupport.java @@ -89,6 +89,10 @@ abstract public class DataSourceServiceSupport extends LockableServiceSupport { } public static DataSource createDataSource(String homeDir) throws IOException { + return createDataSource(homeDir, "derbydb"); + } + + public static DataSource createDataSource(String homeDir, String dbName) throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", homeDir); @@ -96,7 +100,7 @@ abstract public class DataSourceServiceSupport extends LockableServiceSupport { System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); - ds.setDatabaseName("derbydb"); + ds.setDatabaseName(dbName); ds.setCreateDatabase("create"); return ds; } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java index ceef43c8cb..02f9a44c72 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java @@ -108,11 +108,15 @@ public class NetworkBrokerDetachTest { @After public void cleanup() throws Exception { - networkedBroker.stop(); - networkedBroker.waitUntilStopped(); + if (networkedBroker != null) { + networkedBroker.stop(); + networkedBroker.waitUntilStopped(); + } - broker.stop(); - broker.waitUntilStopped(); + if (broker != null) { + broker.stop(); + broker.waitUntilStopped(); + } } @Test diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java index 4881b2f252..aa56862bf1 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java @@ -16,19 +16,43 @@ */ package org.apache.activemq.store.jdbc; +import java.sql.SQLException; +import java.util.LinkedList; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.network.NetworkBrokerDetachTest; import org.apache.derby.jdbc.EmbeddedDataSource; +import org.junit.After; public class JDBCNetworkBrokerDetachTest extends NetworkBrokerDetachTest { + LinkedList dataSources = new LinkedList<>(); protected void configureBroker(BrokerService broker) throws Exception { JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter(); - EmbeddedDataSource dataSource = (EmbeddedDataSource) jdbc.getDataSource(); - dataSource.setDatabaseName(broker.getBrokerName()); - dataSource.getConnection().close(); // ensure derby for brokerName is initialized + try { + EmbeddedDataSource dataSource = (EmbeddedDataSource) DataSourceServiceSupport.createDataSource(jdbc.getDataDirectoryFile().getCanonicalPath(), broker.getBrokerName()); + dataSource.getConnection().close(); // ensure derby for brokerName is initialized + jdbc.setDataSource(dataSource); + dataSources.add(dataSource); + } catch (SQLException e) { + e.printStackTrace(); + Exception n = e.getNextException(); + while (n != null) { + n.printStackTrace(); + if (n instanceof SQLException) { + n = ((SQLException) n).getNextException(); + } + } + throw e; + } broker.setPersistenceAdapter(jdbc); broker.setUseVirtualTopics(false); } - + + @After + public void shutdownDataSources() throws Exception { + for (EmbeddedDataSource ds: dataSources) { + DataSourceServiceSupport.shutdownDefaultDataSource(ds); + } + dataSources.clear(); + } } From d5c25c027b42000520ffa68a64fde75b1d4a1bf7 Mon Sep 17 00:00:00 2001 From: gtully Date: Wed, 17 Jun 2015 14:29:28 +0100 Subject: [PATCH 29/52] disable periodic expiry b/c that will page in and effect the usage assertions if the test lasts for more than 30s. read ci --- .../test/java/org/apache/activemq/usecases/MemoryLimitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java index 3e3dcff893..d2b1be8d86 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java @@ -66,8 +66,8 @@ public class MemoryLimitTest extends TestSupport { PolicyMap policyMap = new PolicyMap(); PolicyEntry policyEntry = new PolicyEntry(); + policyEntry.setExpireMessagesPeriod(0); // when this fires it will consume 2*pageSize mem which will throw the test policyEntry.setProducerFlowControl(false); - policyEntry.setExpireMessagesPeriod(0); policyMap.put(new ActiveMQQueue(">"), policyEntry); broker.setDestinationPolicy(policyMap); From 428fc82c8cad36fe600a68cffeb3c4161a345a17 Mon Sep 17 00:00:00 2001 From: gtully Date: Wed, 17 Jun 2015 15:04:29 +0100 Subject: [PATCH 30/52] AMQ5266Test can take 8mins locally - exclude from quick tests --- activemq-unit-tests/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/activemq-unit-tests/pom.xml b/activemq-unit-tests/pom.xml index 7ea4ce3263..7a18a1ef81 100755 --- a/activemq-unit-tests/pom.xml +++ b/activemq-unit-tests/pom.xml @@ -1028,6 +1028,7 @@ org/apache/activemq/store/kahadb/disk/index/ListIndexTest.* org/apache/activemq/store/kahadb/disk/util/DataByteArrayInputStreamTest.* org/apache/activemq/bugs/AMQ5266StarvedConsumerTest.* + org/apache/activemq/bugs/AMQ5266Test.* From fc3e0261229bb90edbcf4eaeabc5ee2e1b57894d Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Wed, 17 Jun 2015 17:47:24 +0000 Subject: [PATCH 31/52] https://issues.apache.org/jira/browse/AMQ-5705 Modifing the AdivsoryBroker to set the originBrokerURL to the transport connector's URL if it has been set versus using a default URL. --- .../activemq/advisory/AdvisoryBroker.java | 8 ++++++- .../activemq/advisory/AdvisoryTests.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java index 7a6915d77e..36f5f0b372 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java +++ b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java @@ -31,6 +31,7 @@ import org.apache.activemq.broker.BrokerFilter; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ProducerBrokerExchange; +import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.broker.region.BaseDestination; import org.apache.activemq.broker.region.Destination; import org.apache.activemq.broker.region.DurableTopicSubscription; @@ -627,7 +628,12 @@ public class AdvisoryBroker extends BrokerFilter { advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID, id); String url = getBrokerService().getVmConnectorURI().toString(); - if (getBrokerService().getDefaultSocketURIString() != null) { + //try and find the URL on the transport connector and use if it exists else + //try and find a default URL + if (context.getConnector() instanceof TransportConnector + && ((TransportConnector) context.getConnector()).getPublishableConnectString() != null) { + url = ((TransportConnector) context.getConnector()).getPublishableConnectString(); + } else if (getBrokerService().getDefaultSocketURIString() != null) { url = getBrokerService().getDefaultSocketURIString(); } advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL, url); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java index ce072aa5fd..0863b3178e 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java @@ -19,6 +19,7 @@ package org.apache.activemq.advisory; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collection; @@ -147,6 +148,11 @@ public class AdvisoryTests { assertNotNull(msg); ActiveMQMessage message = (ActiveMQMessage) msg; ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + + //This should always be tcp:// because that is the transport that is used to connect even though + //the nio transport is the first one in the list + assertTrue(((String)message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)).startsWith("tcp://")); + //Add assertion to make sure body is included for advisory topics //when includeBodyForAdvisory is true assertIncludeBodyForAdvisory(payload); @@ -177,6 +183,11 @@ public class AdvisoryTests { ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); String originalId = payload.getJMSMessageID(); assertEquals(originalId, id); + + //This should always be tcp:// because that is the transport that is used to connect even though + //the nio transport is the first one in the list + assertTrue(((String)message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)).startsWith("tcp://")); + //Add assertion to make sure body is included for advisory topics //when includeBodyForAdvisory is true assertIncludeBodyForAdvisory(payload); @@ -204,6 +215,10 @@ public class AdvisoryTests { assertNotNull(msg); ActiveMQMessage message = (ActiveMQMessage) msg; ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + + //This should be set + assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)); + //Add assertion to make sure body is included for advisory topics //when includeBodyForAdvisory is true assertIncludeBodyForAdvisory(payload); @@ -235,6 +250,8 @@ public class AdvisoryTests { assertNotNull(msg); ActiveMQMessage message = (ActiveMQMessage) msg; ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + //This should be set + assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)); //Add assertion to make sure body is included for DLQ advisory topics //when includeBodyForAdvisory is true assertIncludeBodyForAdvisory(payload); @@ -265,6 +282,10 @@ public class AdvisoryTests { assertNotNull(msg); ActiveMQMessage message = (ActiveMQMessage) msg; ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure(); + + //This should be set + assertNotNull(message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)); + //Add assertion to make sure body is included for advisory topics //when includeBodyForAdvisory is true assertIncludeBodyForAdvisory(payload); @@ -319,6 +340,7 @@ public class AdvisoryTests { pMap.setDefaultEntry(policy); answer.setDestinationPolicy(pMap); + answer.addConnector("nio://localhost:0"); answer.addConnector(bindAddress); answer.setDeleteAllMessagesOnStartup(true); } From b40dc4cc5452455dd93f53abf71e92bb6cd0b9cc Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Wed, 17 Jun 2015 13:23:08 +0000 Subject: [PATCH 32/52] https://issues.apache.org/jira/browse/AMQ-5668 This commit fixes a race condition in AbstractStoreCursor setLastCacheId that could cause a null pointer exception in certain cases. --- .../region/cursors/AbstractStoreCursor.java | 66 +++++++------ .../cursors/AbstractStoreCursorNpeTest.java | 93 +++++++++++++++++++ 2 files changed, 130 insertions(+), 29 deletions(-) create mode 100755 activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursorNpeTest.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursor.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursor.java index 07d4351778..4bdd7f6eec 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursor.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursor.java @@ -58,15 +58,15 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i this.batchList = new OrderedPendingList(); } } - - + + public final synchronized void start() throws Exception{ if (!isStarted()) { super.start(); resetBatch(); resetSize(); setCacheEnabled(size==0&&useCache); - } + } } protected void resetSize() { @@ -84,7 +84,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i gc(); } - + public final boolean recoverMessage(Message message) throws Exception { return recoverMessage(message,false); } @@ -148,12 +148,12 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i clearIterator(true); size(); } - - + + public synchronized void release() { clearIterator(false); } - + private synchronized void clearIterator(boolean ensureIterator) { boolean haveIterator = this.iterator != null; this.iterator=null; @@ -161,7 +161,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i ensureIterator(); } } - + private synchronized void ensureIterator() { if(this.iterator==null) { this.iterator=this.batchList.iterator(); @@ -171,8 +171,8 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i public final void finished() { } - - + + public final synchronized boolean hasNext() { if (batchList.isEmpty()) { try { @@ -185,8 +185,8 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i ensureIterator(); return this.iterator.hasNext(); } - - + + public final synchronized MessageReference next() { MessageReference result = null; if (!this.batchList.isEmpty()&&this.iterator.hasNext()) { @@ -198,7 +198,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i } return result; } - + public synchronized boolean addMessageLast(MessageReference node) throws Exception { boolean disableCache = false; if (hasSpace()) { @@ -314,23 +314,31 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i } private void setLastCachedId(final int index, MessageId candidate) { - if (lastCachedIds[index] == null || lastCachedIds[index].getFutureOrSequenceLong() == null) { // possibly null for topics - lastCachedIds[index] = candidate; - } else if (Long.compare(((Long) candidate.getFutureOrSequenceLong()), ((Long) lastCachedIds[index].getFutureOrSequenceLong())) > 0) { + MessageId lastCacheId = lastCachedIds[index]; + if (lastCacheId == null) { lastCachedIds[index] = candidate; + } else { + Object lastCacheFutureOrSequenceLong = lastCacheId.getFutureOrSequenceLong(); + Object candidateOrSequenceLong = candidate.getFutureOrSequenceLong(); + if (lastCacheFutureOrSequenceLong == null) { // possibly null for topics + lastCachedIds[index] = candidate; + } else if (candidateOrSequenceLong != null && + Long.compare(((Long) candidateOrSequenceLong), ((Long) lastCacheFutureOrSequenceLong)) > 0) { + lastCachedIds[index] = candidate; + } } } protected void setBatch(MessageId messageId) throws Exception { } - + public synchronized void addMessageFirst(MessageReference node) throws Exception { setCacheEnabled(false); size++; } - + public final synchronized void remove() { size--; if (iterator!=null) { @@ -341,20 +349,20 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i } } - + public final synchronized void remove(MessageReference node) { if (batchList.remove(node) != null) { size--; setCacheEnabled(false); } } - - + + public final synchronized void clear() { gc(); } - - + + public synchronized void gc() { for (MessageReference msg : batchList) { rollback(msg.getMessageId()); @@ -385,14 +393,14 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i } } } - - + + public final synchronized boolean isEmpty() { // negative means more messages added to store through queue.send since last reset return size == 0; } - + public final synchronized boolean hasMessagesBufferedToDeliver() { return !batchList.isEmpty(); } @@ -413,13 +421,13 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i + ",lastSyncCachedId:" + lastCachedIds[SYNC_ADD] + ",lastSyncCachedId-seq:" + (lastCachedIds[SYNC_ADD] != null ? lastCachedIds[SYNC_ADD].getFutureOrSequenceLong() : "null") + ",lastAsyncCachedId:" + lastCachedIds[ASYNC_ADD] + ",lastAsyncCachedId-seq:" + (lastCachedIds[ASYNC_ADD] != null ? lastCachedIds[ASYNC_ADD].getFutureOrSequenceLong() : "null"); } - + protected abstract void doFillBatch() throws Exception; - + protected abstract void resetBatch(); protected abstract int getStoreSize(); - + protected abstract boolean isStoreEmpty(); public Subscription getSubscription() { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursorNpeTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursorNpeTest.java new file mode 100755 index 0000000000..4d47165b9f --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractStoreCursorNpeTest.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.broker.region.cursors; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.activemq.test.TestSupport; + +/** + * This test shows that a null pointer exception will not occur when unsubscribing from a + * subscription while a producer is sending messages rapidly to the topic. A null pointer + * exception was occurring in the setLastCachedId method of AbstractMessageCursor due to + * a race condition. If this test is run before the patch that is applied in this commit + * on AbstractStoreCusor, it will consistently fail with a NPE. + * + */ +public class AbstractStoreCursorNpeTest extends TestSupport { + + protected Connection connection; + protected Session session; + protected MessageConsumer consumer; + protected MessageProducer producer; + protected Topic destination; + + + public void testSetLastCachedIdNPE() throws Exception { + connection = createConnection(); + connection.setClientID("clientId"); + connection.start(); + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + destination = session.createTopic("test.topic"); + producer = session.createProducer(destination); + producer.setDeliveryMode(DeliveryMode.PERSISTENT); + + + Connection durableCon = createConnection(); + durableCon.setClientID("testCons"); + durableCon.start(); + final Session durSession = durableCon.createSession(false, Session.AUTO_ACKNOWLEDGE); + + //In a new thread rapidly subscribe and unsubscribe to a durable + ExecutorService executorService = Executors.newCachedThreadPool(); + executorService.execute(new Runnable() { + @Override + public void run() { + try{ + //Repeatedly create a durable subscription and then unsubscribe which used to + //cause a NPE while messages were sending + while(true) { + MessageConsumer cons = durSession.createDurableSubscriber(durSession.createTopic("test.topic"), "sub1"); + Thread.sleep(100); + cons.close(); + durSession.unsubscribe("sub1"); + } + } catch (Exception ignored) { + ignored.printStackTrace(); + } + } + }); + + TextMessage myMessage = new ActiveMQTextMessage(); + myMessage.setText("test"); + //Make sure that we can send a bunch of messages without a NPE + //This would fail if the patch is not applied + for (int i = 0; i < 10000; i++) { + producer.send(myMessage); + } + } +} From 833d30837b0b306e8d9b0a2e54331c25f7c5c292 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Thu, 18 Jun 2015 14:25:07 -0400 Subject: [PATCH 33/52] https://issues.apache.org/jira/browse/AMQ-5848 Introduce OpenWire v11 which adds noLocal to the SubscriptionInfo, if configured KahaDB can store that version and the noLocal value is recovered from the store. --- .../activemq/transport/amqp/AMQ4563Test.java | 4 +- .../transport/amqp/AmqpTestSupport.java | 6 +- .../amqp/interop/AmqpDurableReceiverTest.java | 2 - .../apache/activemq/broker/region/Topic.java | 30 +- .../activemq/broker/region/TopicRegion.java | 3 +- activemq-client/pom.xml | 58 +- .../apache/activemq/command/CommandTypes.java | 6 +- .../activemq/command/SubscriptionInfo.java | 23 +- .../v11/ActiveMQBlobMessageMarshaller.java | 139 ++++ .../v11/ActiveMQBytesMessageMarshaller.java | 114 ++++ .../v11/ActiveMQDestinationMarshaller.java | 114 ++++ .../v11/ActiveMQMapMessageMarshaller.java | 114 ++++ .../v11/ActiveMQMessageMarshaller.java | 114 ++++ .../v11/ActiveMQObjectMessageMarshaller.java | 114 ++++ .../openwire/v11/ActiveMQQueueMarshaller.java | 114 ++++ .../v11/ActiveMQStreamMessageMarshaller.java | 114 ++++ .../ActiveMQTempDestinationMarshaller.java | 99 +++ .../v11/ActiveMQTempQueueMarshaller.java | 114 ++++ .../v11/ActiveMQTempTopicMarshaller.java | 114 ++++ .../v11/ActiveMQTextMessageMarshaller.java | 114 ++++ .../openwire/v11/ActiveMQTopicMarshaller.java | 114 ++++ .../openwire/v11/BaseCommandMarshaller.java | 118 ++++ .../v11/BaseDataStreamMarshaller.java | 644 ++++++++++++++++++ .../openwire/v11/BrokerIdMarshaller.java | 129 ++++ .../openwire/v11/BrokerInfoMarshaller.java | 206 ++++++ .../v11/ConnectionControlMarshaller.java | 169 +++++ .../v11/ConnectionErrorMarshaller.java | 134 ++++ .../openwire/v11/ConnectionIdMarshaller.java | 129 ++++ .../v11/ConnectionInfoMarshaller.java | 201 ++++++ .../v11/ConsumerControlMarshaller.java | 158 +++++ .../openwire/v11/ConsumerIdMarshaller.java | 139 ++++ .../openwire/v11/ConsumerInfoMarshaller.java | 260 +++++++ .../v11/ControlCommandMarshaller.java | 129 ++++ .../v11/DataArrayResponseMarshaller.java | 151 ++++ .../openwire/v11/DataResponseMarshaller.java | 129 ++++ .../v11/DestinationInfoMarshaller.java | 170 +++++ .../v11/DiscoveryEventMarshaller.java | 134 ++++ .../v11/ExceptionResponseMarshaller.java | 129 ++++ .../openwire/v11/FlushCommandMarshaller.java | 114 ++++ .../v11/IntegerResponseMarshaller.java | 128 ++++ .../v11/JournalQueueAckMarshaller.java | 134 ++++ .../v11/JournalTopicAckMarshaller.java | 154 +++++ .../openwire/v11/JournalTraceMarshaller.java | 129 ++++ .../v11/JournalTransactionMarshaller.java | 138 ++++ .../openwire/v11/KeepAliveInfoMarshaller.java | 114 ++++ .../v11/LastPartialCommandMarshaller.java | 114 ++++ .../v11/LocalTransactionIdMarshaller.java | 134 ++++ .../openwire/v11/MarshallerFactory.java | 109 +++ .../openwire/v11/MessageAckMarshaller.java | 162 +++++ .../v11/MessageDispatchMarshaller.java | 143 ++++ ...MessageDispatchNotificationMarshaller.java | 144 ++++ .../openwire/v11/MessageIdMarshaller.java | 144 ++++ .../openwire/v11/MessageMarshaller.java | 316 +++++++++ .../openwire/v11/MessagePullMarshaller.java | 149 ++++ .../v11/NetworkBridgeFilterMarshaller.java | 137 ++++ .../v11/PartialCommandMarshaller.java | 133 ++++ .../openwire/v11/ProducerAckMarshaller.java | 133 ++++ .../openwire/v11/ProducerIdMarshaller.java | 139 ++++ .../openwire/v11/ProducerInfoMarshaller.java | 170 +++++ .../openwire/v11/RemoveInfoMarshaller.java | 134 ++++ .../v11/RemoveSubscriptionInfoMarshaller.java | 139 ++++ .../openwire/v11/ReplayCommandMarshaller.java | 132 ++++ .../openwire/v11/ResponseMarshaller.java | 128 ++++ .../openwire/v11/SessionIdMarshaller.java | 134 ++++ .../openwire/v11/SessionInfoMarshaller.java | 129 ++++ .../openwire/v11/ShutdownInfoMarshaller.java | 114 ++++ .../v11/SubscriptionInfoMarshaller.java | 154 +++++ .../openwire/v11/TransactionIdMarshaller.java | 99 +++ .../v11/TransactionInfoMarshaller.java | 138 ++++ .../v11/WireFormatInfoMarshaller.java | 154 +++++ .../v11/XATransactionIdMarshaller.java | 138 ++++ .../console/command/store/StoreExporter.java | 4 +- activemq-openwire-generator/pom.xml | 4 +- ...ConcurrentProducerDurableConsumerTest.java | 124 ++-- .../DurableSubscriptionWithNoLocalTest.java | 345 ++++++++++ 75 files changed, 9716 insertions(+), 145 deletions(-) create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBlobMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBytesMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQDestinationMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMapMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQObjectMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQQueueMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQStreamMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempDestinationMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempQueueMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempTopicMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTextMessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTopicMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionErrorMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerControlMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ControlCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataArrayResponseMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataResponseMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/DestinationInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/DiscoveryEventMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ExceptionResponseMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/FlushCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/IntegerResponseMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalQueueAckMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTopicAckMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTraceMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTransactionMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/KeepAliveInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/LastPartialCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/LocalTransactionIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MarshallerFactory.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageAckMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchNotificationMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessagePullMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/NetworkBridgeFilterMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerAckMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveSubscriptionInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ReplayCommandMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ResponseMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/ShutdownInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/SubscriptionInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionIdMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java create mode 100644 activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionWithNoLocalTest.java diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4563Test.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4563Test.java index 88e0a44c30..099944d0d5 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4563Test.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4563Test.java @@ -39,7 +39,7 @@ import org.junit.Test; public class AMQ4563Test extends AmqpTestSupport { - public static final String KAHADB_DIRECTORY = "target/activemq-data/kahadb-amq4563"; + public static final String KAHADB_DIRECTORY = "./target/activemq-data/kahadb-amq4563"; @Test(timeout = 60000) public void testMessagesAreAckedAMQProducer() throws Exception { @@ -224,7 +224,7 @@ public class AMQ4563Test extends AmqpTestSupport { } @Override - protected int getstoreOpenWireVersion() { + protected int getStoreOpenWireVersion() { return 10; } } diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java index 6f00ab20f5..615376290a 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java @@ -102,7 +102,7 @@ public class AmqpTestSupport { KahaDBStore kaha = new KahaDBStore(); kaha.setDirectory(new File(KAHADB_DIRECTORY + getTestName())); brokerService.setPersistenceAdapter(kaha); - brokerService.setStoreOpenWireVersion(getstoreOpenWireVersion()); + brokerService.setStoreOpenWireVersion(getStoreOpenWireVersion()); } brokerService.setSchedulerSupport(false); brokerService.setAdvisorySupport(false); @@ -188,8 +188,8 @@ public class AmqpTestSupport { return true; } - protected int getstoreOpenWireVersion() { - return OpenWireFormat.DEFAULT_VERSION; + protected int getStoreOpenWireVersion() { + return OpenWireFormat.DEFAULT_WIRE_VERSION; } protected boolean isUseOpenWireConnector() { diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java index 1b944a983e..e2d24959da 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpDurableReceiverTest.java @@ -35,7 +35,6 @@ import org.apache.qpid.proton.amqp.messaging.Source; import org.apache.qpid.proton.amqp.messaging.TerminusDurability; import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy; import org.apache.qpid.proton.engine.Receiver; -import org.junit.Ignore; import org.junit.Test; /** @@ -293,7 +292,6 @@ public class AmqpDurableReceiverTest extends AmqpClientTestSupport { connection.close(); } - @Ignore("Broker doesn't currently recover noLocal state") @Test(timeout = 60000) public void testLookupExistingSubscriptionAfterRestartWithSelectorAndNoLocal() throws Exception { diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java index 21e0c1b65a..bda000b696 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java @@ -39,6 +39,7 @@ import org.apache.activemq.broker.region.policy.SimpleDispatchPolicy; import org.apache.activemq.broker.region.policy.SubscriptionRecoveryPolicy; import org.apache.activemq.broker.util.InsertionCountList; import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.ExceptionResponse; import org.apache.activemq.command.Message; import org.apache.activemq.command.MessageAck; @@ -209,6 +210,17 @@ public class Topic extends BaseDestination implements Task { } } + private boolean hasDurableSubChanged(SubscriptionInfo info1, ConsumerInfo info2) { + if (info1.getSelector() != null ^ info2.getSelector() != null) { + return true; + } + if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { + return true; + } + + return false; + } + public void activate(ConnectionContext context, final DurableTopicSubscription subscription) throws Exception { // synchronize with dispatch method so that no new messages are sent // while we are recovering a subscription to avoid out of order messages. @@ -222,12 +234,10 @@ public class Topic extends BaseDestination implements Task { // Recover the durable subscription. String clientId = subscription.getSubscriptionKey().getClientId(); String subscriptionName = subscription.getSubscriptionKey().getSubscriptionName(); - String selector = subscription.getConsumerInfo().getSelector(); SubscriptionInfo info = topicStore.lookupSubscription(clientId, subscriptionName); if (info != null) { // Check to see if selector changed. - String s1 = info.getSelector(); - if (s1 == null ^ selector == null || (s1 != null && !s1.equals(selector))) { + if (hasDurableSubChanged(info, subscription.getConsumerInfo())) { // Need to delete the subscription topicStore.deleteSubscription(clientId, subscriptionName); info = null; @@ -247,9 +257,10 @@ public class Topic extends BaseDestination implements Task { if (info == null) { info = new SubscriptionInfo(); info.setClientId(clientId); - info.setSelector(selector); + info.setSelector(subscription.getConsumerInfo().getSelector()); info.setSubscriptionName(subscriptionName); info.setDestination(getActiveMQDestination()); + info.setNoLocal(subscription.getConsumerInfo().isNoLocal()); // This destination is an actual destination id. info.setSubscribedDestination(subscription.getConsumerInfo().getDestination()); // This destination might be a pattern @@ -816,17 +827,6 @@ public class Topic extends BaseDestination implements Task { } } - private void rollback(MessageId poisoned) { - dispatchLock.readLock().lock(); - try { - for (DurableTopicSubscription durableTopicSubscription : durableSubscribers.values()) { - durableTopicSubscription.getPending().rollback(poisoned); - } - } finally { - dispatchLock.readLock().unlock(); - } - } - public Map getDurableTopicSubs() { return durableSubscribers; } diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java index 684ac88895..ca79b25930 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java @@ -136,7 +136,7 @@ public class TopicRegion extends AbstractRegion { destinationsLock.readLock().lock(); try { for (Destination dest : destinations.values()) { - //Account for virtual destinations + // Account for virtual destinations if (dest instanceof Topic){ Topic topic = (Topic)dest; topic.deleteSubscription(context, key); @@ -301,6 +301,7 @@ public class TopicRegion extends AbstractRegion { rc.setSubscriptionName(info.getSubscriptionName()); rc.setDestination(info.getSubscribedDestination()); rc.setConsumerId(createConsumerId()); + rc.setNoLocal(info.isNoLocal()); return rc; } diff --git a/activemq-client/pom.xml b/activemq-client/pom.xml index 3809a71efd..a45bfae200 100755 --- a/activemq-client/pom.xml +++ b/activemq-client/pom.xml @@ -252,37 +252,37 @@ - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - - javacc-maven-plugin - - [2.6,) - - javacc - - - + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + + javacc-maven-plugin + + [2.6,) + + javacc + + + true - - - - - - - + + + + + + + @@ -308,7 +308,7 @@ Running OpenWire Generator - + diff --git a/activemq-client/src/main/java/org/apache/activemq/command/CommandTypes.java b/activemq-client/src/main/java/org/apache/activemq/command/CommandTypes.java index 00681fa426..49ed9cbd1a 100755 --- a/activemq-client/src/main/java/org/apache/activemq/command/CommandTypes.java +++ b/activemq-client/src/main/java/org/apache/activemq/command/CommandTypes.java @@ -18,13 +18,13 @@ package org.apache.activemq.command; /** * Holds the command id constants used by the command objects. - * - * + * + * */ public interface CommandTypes { // What is the latest version of the openwire protocol - byte PROTOCOL_VERSION = 10; + byte PROTOCOL_VERSION = 11; // What is the latest version of the openwire protocol used in the stores byte PROTOCOL_STORE_VERSION = 6; diff --git a/activemq-client/src/main/java/org/apache/activemq/command/SubscriptionInfo.java b/activemq-client/src/main/java/org/apache/activemq/command/SubscriptionInfo.java index 7776b53513..3159e335c3 100755 --- a/activemq-client/src/main/java/org/apache/activemq/command/SubscriptionInfo.java +++ b/activemq-client/src/main/java/org/apache/activemq/command/SubscriptionInfo.java @@ -20,9 +20,9 @@ import org.apache.activemq.util.IntrospectionSupport; /** * Used to represent a durable subscription. - * + * * @openwire:marshaller code="55" - * + * */ public class SubscriptionInfo implements DataStructure { @@ -33,6 +33,7 @@ public class SubscriptionInfo implements DataStructure { protected String clientId; protected String subscriptionName; protected String selector; + protected boolean noLocal; public SubscriptionInfo() {} @@ -41,6 +42,7 @@ public class SubscriptionInfo implements DataStructure { this.subscriptionName = subscriptionName; } + @Override public byte getDataStructureType() { return DATA_STRUCTURE_TYPE; } @@ -59,7 +61,7 @@ public class SubscriptionInfo implements DataStructure { /** * This is the a resolved destination that the subscription is receiving * messages from. This will never be a pattern or a composite destination. - * + * * @openwire:property version=1 cache=true */ public ActiveMQDestination getDestination() { @@ -103,6 +105,7 @@ public class SubscriptionInfo implements DataStructure { this.subscriptionName = subscriptionName; } + @Override public boolean isMarshallAware() { return false; } @@ -139,10 +142,10 @@ public class SubscriptionInfo implements DataStructure { * The destination the client originally subscribed to.. This may not match * the {@see getDestination} method if the subscribed destination uses * patterns or composites. - * + * * If the subscribed destinationis not set, this just ruturns the * desitination. - * + * * @openwire:property version=3 */ public ActiveMQDestination getSubscribedDestination() { @@ -156,4 +159,14 @@ public class SubscriptionInfo implements DataStructure { this.subscribedDestination = subscribedDestination; } + /** + * @openwire:property version=11 + */ + public boolean isNoLocal() { + return noLocal; + } + + public void setNoLocal(boolean noLocal) { + this.noLocal = noLocal; + } } diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBlobMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBlobMessageMarshaller.java new file mode 100644 index 0000000000..3f0492fbfa --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBlobMessageMarshaller.java @@ -0,0 +1,139 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQBlobMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQBlobMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQBlobMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQBlobMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ActiveMQBlobMessage info = (ActiveMQBlobMessage)o; + info.setRemoteBlobUrl(tightUnmarshalString(dataIn, bs)); + info.setMimeType(tightUnmarshalString(dataIn, bs)); + info.setDeletedByBroker(bs.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ActiveMQBlobMessage info = (ActiveMQBlobMessage)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getRemoteBlobUrl(), bs); + rc += tightMarshalString1(info.getMimeType(), bs); + bs.writeBoolean(info.isDeletedByBroker()); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ActiveMQBlobMessage info = (ActiveMQBlobMessage)o; + tightMarshalString2(info.getRemoteBlobUrl(), dataOut, bs); + tightMarshalString2(info.getMimeType(), dataOut, bs); + bs.readBoolean(); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ActiveMQBlobMessage info = (ActiveMQBlobMessage)o; + info.setRemoteBlobUrl(looseUnmarshalString(dataIn)); + info.setMimeType(looseUnmarshalString(dataIn)); + info.setDeletedByBroker(dataIn.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ActiveMQBlobMessage info = (ActiveMQBlobMessage)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getRemoteBlobUrl(), dataOut); + looseMarshalString(info.getMimeType(), dataOut); + dataOut.writeBoolean(info.isDeletedByBroker()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBytesMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBytesMessageMarshaller.java new file mode 100644 index 0000000000..96fb9e655e --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQBytesMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQBytesMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQBytesMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQBytesMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQBytesMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQDestinationMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQDestinationMarshaller.java new file mode 100644 index 0000000000..aaa4d70f54 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQDestinationMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQDestinationMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public abstract class ActiveMQDestinationMarshaller extends BaseDataStreamMarshaller { + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ActiveMQDestination info = (ActiveMQDestination)o; + info.setPhysicalName(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ActiveMQDestination info = (ActiveMQDestination)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getPhysicalName(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ActiveMQDestination info = (ActiveMQDestination)o; + tightMarshalString2(info.getPhysicalName(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ActiveMQDestination info = (ActiveMQDestination)o; + info.setPhysicalName(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ActiveMQDestination info = (ActiveMQDestination)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getPhysicalName(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMapMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMapMessageMarshaller.java new file mode 100644 index 0000000000..d5c814b920 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMapMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQMapMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQMapMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQMapMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQMapMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMessageMarshaller.java new file mode 100644 index 0000000000..9fa1d5e4a2 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQMessageMarshaller extends MessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQObjectMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQObjectMessageMarshaller.java new file mode 100644 index 0000000000..464f5e0567 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQObjectMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQObjectMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQObjectMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQObjectMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQObjectMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQQueueMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQQueueMarshaller.java new file mode 100644 index 0000000000..2235890569 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQQueueMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQQueueMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQQueueMarshaller extends ActiveMQDestinationMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQQueue.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQQueue(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQStreamMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQStreamMessageMarshaller.java new file mode 100644 index 0000000000..6094fed410 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQStreamMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQStreamMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQStreamMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQStreamMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQStreamMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempDestinationMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempDestinationMarshaller.java new file mode 100644 index 0000000000..e54e47c5db --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempDestinationMarshaller.java @@ -0,0 +1,99 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQTempDestinationMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public abstract class ActiveMQTempDestinationMarshaller extends ActiveMQDestinationMarshaller { + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempQueueMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempQueueMarshaller.java new file mode 100644 index 0000000000..3e459949b2 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempQueueMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQTempQueueMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQTempQueueMarshaller extends ActiveMQTempDestinationMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQTempQueue.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQTempQueue(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempTopicMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempTopicMarshaller.java new file mode 100644 index 0000000000..ea8a0a64ec --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTempTopicMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQTempTopicMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQTempTopicMarshaller extends ActiveMQTempDestinationMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQTempTopic.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQTempTopic(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTextMessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTextMessageMarshaller.java new file mode 100644 index 0000000000..d688fcd5a8 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTextMessageMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQTextMessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQTextMessageMarshaller extends ActiveMQMessageMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQTextMessage.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQTextMessage(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTopicMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTopicMarshaller.java new file mode 100644 index 0000000000..2dd1b0b507 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ActiveMQTopicMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ActiveMQTopicMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ActiveMQTopicMarshaller extends ActiveMQDestinationMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ActiveMQTopic.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ActiveMQTopic(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseCommandMarshaller.java new file mode 100644 index 0000000000..ff715086e2 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseCommandMarshaller.java @@ -0,0 +1,118 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for BaseCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public abstract class BaseCommandMarshaller extends BaseDataStreamMarshaller { + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + BaseCommand info = (BaseCommand)o; + info.setCommandId(dataIn.readInt()); + info.setResponseRequired(bs.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + BaseCommand info = (BaseCommand)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + bs.writeBoolean(info.isResponseRequired()); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + BaseCommand info = (BaseCommand)o; + dataOut.writeInt(info.getCommandId()); + bs.readBoolean(); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + BaseCommand info = (BaseCommand)o; + info.setCommandId(dataIn.readInt()); + info.setResponseRequired(dataIn.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + BaseCommand info = (BaseCommand)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getCommandId()); + dataOut.writeBoolean(info.isResponseRequired()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java new file mode 100644 index 0000000000..c61d16fa32 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java @@ -0,0 +1,644 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.lang.reflect.Constructor; +import org.apache.activemq.command.DataStructure; +import org.apache.activemq.openwire.BooleanStream; +import org.apache.activemq.openwire.DataStreamMarshaller; +import org.apache.activemq.openwire.OpenWireFormat; +import org.apache.activemq.util.ByteSequence; + +public abstract class BaseDataStreamMarshaller implements DataStreamMarshaller { + + public static final Constructor STACK_TRACE_ELEMENT_CONSTRUCTOR; + + static { + Constructor constructor = null; + try { + constructor = StackTraceElement.class.getConstructor(new Class[] {String.class, String.class, + String.class, int.class}); + } catch (Throwable e) { + } + STACK_TRACE_ELEMENT_CONSTRUCTOR = constructor; + } + + public abstract byte getDataStructureType(); + + public abstract DataStructure createObject(); + + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + return 0; + } + + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) + throws IOException { + } + + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) + throws IOException { + } + + public int tightMarshalLong1(OpenWireFormat wireFormat, long o, BooleanStream bs) throws IOException { + if (o == 0) { + bs.writeBoolean(false); + bs.writeBoolean(false); + return 0; + } else if ((o & 0xFFFFFFFFFFFF0000L) == 0) { + bs.writeBoolean(false); + bs.writeBoolean(true); + return 2; + } else if ((o & 0xFFFFFFFF00000000L) == 0) { + bs.writeBoolean(true); + bs.writeBoolean(false); + return 4; + } else { + bs.writeBoolean(true); + bs.writeBoolean(true); + return 8; + } + } + + public void tightMarshalLong2(OpenWireFormat wireFormat, long o, DataOutput dataOut, BooleanStream bs) + throws IOException { + if (bs.readBoolean()) { + if (bs.readBoolean()) { + dataOut.writeLong(o); + } else { + dataOut.writeInt((int)o); + } + } else { + if (bs.readBoolean()) { + dataOut.writeShort((int)o); + } + } + } + + public long tightUnmarshalLong(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) + throws IOException { + if (bs.readBoolean()) { + if (bs.readBoolean()) { + return dataIn.readLong(); + } else { + return toLong(dataIn.readInt()); + } + } else { + if (bs.readBoolean()) { + return toLong(dataIn.readShort()); + } else { + return 0; + } + } + } + + protected long toLong(short value) { + // lets handle negative values + long answer = value; + return answer & 0xffffL; + } + + protected long toLong(int value) { + // lets handle negative values + long answer = value; + return answer & 0xffffffffL; + } + + protected DataStructure tightUnmarsalNestedObject(OpenWireFormat wireFormat, DataInput dataIn, + BooleanStream bs) throws IOException { + return wireFormat.tightUnmarshalNestedObject(dataIn, bs); + } + + protected int tightMarshalNestedObject1(OpenWireFormat wireFormat, DataStructure o, BooleanStream bs) + throws IOException { + return wireFormat.tightMarshalNestedObject1(o, bs); + } + + protected void tightMarshalNestedObject2(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut, + BooleanStream bs) throws IOException { + wireFormat.tightMarshalNestedObject2(o, dataOut, bs); + } + + protected DataStructure tightUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn, + BooleanStream bs) throws IOException { + if (wireFormat.isCacheEnabled()) { + if (bs.readBoolean()) { + short index = dataIn.readShort(); + DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs); + wireFormat.setInUnmarshallCache(index, object); + return object; + } else { + short index = dataIn.readShort(); + return wireFormat.getFromUnmarshallCache(index); + } + } else { + return wireFormat.tightUnmarshalNestedObject(dataIn, bs); + } + } + + protected int tightMarshalCachedObject1(OpenWireFormat wireFormat, DataStructure o, BooleanStream bs) + throws IOException { + if (wireFormat.isCacheEnabled()) { + Short index = wireFormat.getMarshallCacheIndex(o); + bs.writeBoolean(index == null); + if (index == null) { + int rc = wireFormat.tightMarshalNestedObject1(o, bs); + wireFormat.addToMarshallCache(o); + return 2 + rc; + } else { + return 2; + } + } else { + return wireFormat.tightMarshalNestedObject1(o, bs); + } + } + + protected void tightMarshalCachedObject2(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut, + BooleanStream bs) throws IOException { + if (wireFormat.isCacheEnabled()) { + Short index = wireFormat.getMarshallCacheIndex(o); + if (bs.readBoolean()) { + dataOut.writeShort(index.shortValue()); + wireFormat.tightMarshalNestedObject2(o, dataOut, bs); + } else { + dataOut.writeShort(index.shortValue()); + } + } else { + wireFormat.tightMarshalNestedObject2(o, dataOut, bs); + } + } + + protected Throwable tightUnmarsalThrowable(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) + throws IOException { + if (bs.readBoolean()) { + String clazz = tightUnmarshalString(dataIn, bs); + String message = tightUnmarshalString(dataIn, bs); + Throwable o = createThrowable(clazz, message); + if (wireFormat.isStackTraceEnabled()) { + if (STACK_TRACE_ELEMENT_CONSTRUCTOR != null) { + StackTraceElement ss[] = new StackTraceElement[dataIn.readShort()]; + for (int i = 0; i < ss.length; i++) { + try { + ss[i] = (StackTraceElement)STACK_TRACE_ELEMENT_CONSTRUCTOR + .newInstance(new Object[] {tightUnmarshalString(dataIn, bs), + tightUnmarshalString(dataIn, bs), + tightUnmarshalString(dataIn, bs), + Integer.valueOf(dataIn.readInt())}); + } catch (IOException e) { + throw e; + } catch (Throwable e) { + } + } + o.setStackTrace(ss); + } else { + short size = dataIn.readShort(); + for (int i = 0; i < size; i++) { + tightUnmarshalString(dataIn, bs); + tightUnmarshalString(dataIn, bs); + tightUnmarshalString(dataIn, bs); + dataIn.readInt(); + } + } + o.initCause(tightUnmarsalThrowable(wireFormat, dataIn, bs)); + + } + return o; + } else { + return null; + } + } + + private Throwable createThrowable(String className, String message) { + try { + Class clazz = Class.forName(className, false, BaseDataStreamMarshaller.class.getClassLoader()); + Constructor constructor = clazz.getConstructor(new Class[] {String.class}); + return (Throwable)constructor.newInstance(new Object[] {message}); + } catch (Throwable e) { + return new Throwable(className + ": " + message); + } + } + + protected int tightMarshalThrowable1(OpenWireFormat wireFormat, Throwable o, BooleanStream bs) + throws IOException { + if (o == null) { + bs.writeBoolean(false); + return 0; + } else { + int rc = 0; + bs.writeBoolean(true); + rc += tightMarshalString1(o.getClass().getName(), bs); + rc += tightMarshalString1(o.getMessage(), bs); + if (wireFormat.isStackTraceEnabled()) { + rc += 2; + StackTraceElement[] stackTrace = o.getStackTrace(); + for (int i = 0; i < stackTrace.length; i++) { + StackTraceElement element = stackTrace[i]; + rc += tightMarshalString1(element.getClassName(), bs); + rc += tightMarshalString1(element.getMethodName(), bs); + rc += tightMarshalString1(element.getFileName(), bs); + rc += 4; + } + rc += tightMarshalThrowable1(wireFormat, o.getCause(), bs); + } + return rc; + } + } + + protected void tightMarshalThrowable2(OpenWireFormat wireFormat, Throwable o, DataOutput dataOut, + BooleanStream bs) throws IOException { + if (bs.readBoolean()) { + tightMarshalString2(o.getClass().getName(), dataOut, bs); + tightMarshalString2(o.getMessage(), dataOut, bs); + if (wireFormat.isStackTraceEnabled()) { + StackTraceElement[] stackTrace = o.getStackTrace(); + dataOut.writeShort(stackTrace.length); + for (int i = 0; i < stackTrace.length; i++) { + StackTraceElement element = stackTrace[i]; + tightMarshalString2(element.getClassName(), dataOut, bs); + tightMarshalString2(element.getMethodName(), dataOut, bs); + tightMarshalString2(element.getFileName(), dataOut, bs); + dataOut.writeInt(element.getLineNumber()); + } + tightMarshalThrowable2(wireFormat, o.getCause(), dataOut, bs); + } + } + } + + @SuppressWarnings("deprecation") + protected String tightUnmarshalString(DataInput dataIn, BooleanStream bs) throws IOException { + if (bs.readBoolean()) { + if (bs.readBoolean()) { + int size = dataIn.readShort(); + byte data[] = new byte[size]; + dataIn.readFully(data); + // Yes deprecated, but we know what we are doing. + // This allows us to create a String from a ASCII byte array. (no UTF-8 decoding) + return new String(data, 0); + } else { + return dataIn.readUTF(); + } + } else { + return null; + } + } + + protected int tightMarshalString1(String value, BooleanStream bs) throws IOException { + bs.writeBoolean(value != null); + if (value != null) { + + int strlen = value.length(); + int utflen = 0; + char[] charr = new char[strlen]; + int c = 0; + boolean isOnlyAscii = true; + + value.getChars(0, strlen, charr, 0); + + for (int i = 0; i < strlen; i++) { + c = charr[i]; + if ((c >= 0x0001) && (c <= 0x007F)) { + utflen++; + } else if (c > 0x07FF) { + utflen += 3; + isOnlyAscii = false; + } else { + isOnlyAscii = false; + utflen += 2; + } + } + + if (utflen >= Short.MAX_VALUE) { + throw new IOException("Encountered a String value that is too long to encode."); + } + bs.writeBoolean(isOnlyAscii); + return utflen + 2; + + } else { + return 0; + } + } + + protected void tightMarshalString2(String value, DataOutput dataOut, BooleanStream bs) throws IOException { + if (bs.readBoolean()) { + // If we verified it only holds ascii values + if (bs.readBoolean()) { + dataOut.writeShort(value.length()); + dataOut.writeBytes(value); + } else { + dataOut.writeUTF(value); + } + } + } + + protected int tightMarshalObjectArray1(OpenWireFormat wireFormat, DataStructure[] objects, + BooleanStream bs) throws IOException { + if (objects != null) { + int rc = 0; + bs.writeBoolean(true); + rc += 2; + for (int i = 0; i < objects.length; i++) { + rc += tightMarshalNestedObject1(wireFormat, objects[i], bs); + } + return rc; + } else { + bs.writeBoolean(false); + return 0; + } + } + + protected void tightMarshalObjectArray2(OpenWireFormat wireFormat, DataStructure[] objects, + DataOutput dataOut, BooleanStream bs) throws IOException { + if (bs.readBoolean()) { + dataOut.writeShort(objects.length); + for (int i = 0; i < objects.length; i++) { + tightMarshalNestedObject2(wireFormat, objects[i], dataOut, bs); + } + } + } + + protected int tightMarshalConstByteArray1(byte[] data, BooleanStream bs, int i) throws IOException { + return i; + } + + protected void tightMarshalConstByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs, int i) + throws IOException { + dataOut.write(data, 0, i); + } + + protected byte[] tightUnmarshalConstByteArray(DataInput dataIn, BooleanStream bs, int i) + throws IOException { + byte data[] = new byte[i]; + dataIn.readFully(data); + return data; + } + + protected int tightMarshalByteArray1(byte[] data, BooleanStream bs) throws IOException { + bs.writeBoolean(data != null); + if (data != null) { + return data.length + 4; + } else { + return 0; + } + } + + protected void tightMarshalByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs) + throws IOException { + if (bs.readBoolean()) { + dataOut.writeInt(data.length); + dataOut.write(data); + } + } + + protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException { + byte rc[] = null; + if (bs.readBoolean()) { + int size = dataIn.readInt(); + rc = new byte[size]; + dataIn.readFully(rc); + } + return rc; + } + + protected int tightMarshalByteSequence1(ByteSequence data, BooleanStream bs) throws IOException { + bs.writeBoolean(data != null); + if (data != null) { + return data.getLength() + 4; + } else { + return 0; + } + } + + protected void tightMarshalByteSequence2(ByteSequence data, DataOutput dataOut, BooleanStream bs) + throws IOException { + if (bs.readBoolean()) { + dataOut.writeInt(data.getLength()); + dataOut.write(data.getData(), data.getOffset(), data.getLength()); + } + } + + protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException { + ByteSequence rc = null; + if (bs.readBoolean()) { + int size = dataIn.readInt(); + byte[] t = new byte[size]; + dataIn.readFully(t); + return new ByteSequence(t, 0, size); + } + return rc; + } + + // + // The loose marshaling logic + // + + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + } + + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + } + + public void looseMarshalLong(OpenWireFormat wireFormat, long o, DataOutput dataOut) throws IOException { + dataOut.writeLong(o); + } + + public long looseUnmarshalLong(OpenWireFormat wireFormat, DataInput dataIn) throws IOException { + return dataIn.readLong(); + } + + protected DataStructure looseUnmarsalNestedObject(OpenWireFormat wireFormat, DataInput dataIn) + throws IOException { + return wireFormat.looseUnmarshalNestedObject(dataIn); + } + + protected void looseMarshalNestedObject(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut) + throws IOException { + wireFormat.looseMarshalNestedObject(o, dataOut); + } + + protected DataStructure looseUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn) + throws IOException { + if (wireFormat.isCacheEnabled()) { + if (dataIn.readBoolean()) { + short index = dataIn.readShort(); + DataStructure object = wireFormat.looseUnmarshalNestedObject(dataIn); + wireFormat.setInUnmarshallCache(index, object); + return object; + } else { + short index = dataIn.readShort(); + return wireFormat.getFromUnmarshallCache(index); + } + } else { + return wireFormat.looseUnmarshalNestedObject(dataIn); + } + } + + protected void looseMarshalCachedObject(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut) + throws IOException { + if (wireFormat.isCacheEnabled()) { + Short index = wireFormat.getMarshallCacheIndex(o); + dataOut.writeBoolean(index == null); + if (index == null) { + index = wireFormat.addToMarshallCache(o); + dataOut.writeShort(index.shortValue()); + wireFormat.looseMarshalNestedObject(o, dataOut); + } else { + dataOut.writeShort(index.shortValue()); + } + } else { + wireFormat.looseMarshalNestedObject(o, dataOut); + } + } + + protected Throwable looseUnmarsalThrowable(OpenWireFormat wireFormat, DataInput dataIn) + throws IOException { + if (dataIn.readBoolean()) { + String clazz = looseUnmarshalString(dataIn); + String message = looseUnmarshalString(dataIn); + Throwable o = createThrowable(clazz, message); + if (wireFormat.isStackTraceEnabled()) { + if (STACK_TRACE_ELEMENT_CONSTRUCTOR != null) { + StackTraceElement ss[] = new StackTraceElement[dataIn.readShort()]; + for (int i = 0; i < ss.length; i++) { + try { + ss[i] = (StackTraceElement)STACK_TRACE_ELEMENT_CONSTRUCTOR + .newInstance(new Object[] {looseUnmarshalString(dataIn), + looseUnmarshalString(dataIn), + looseUnmarshalString(dataIn), + Integer.valueOf(dataIn.readInt())}); + } catch (IOException e) { + throw e; + } catch (Throwable e) { + } + } + o.setStackTrace(ss); + } else { + short size = dataIn.readShort(); + for (int i = 0; i < size; i++) { + looseUnmarshalString(dataIn); + looseUnmarshalString(dataIn); + looseUnmarshalString(dataIn); + dataIn.readInt(); + } + } + o.initCause(looseUnmarsalThrowable(wireFormat, dataIn)); + + } + return o; + } else { + return null; + } + } + + protected void looseMarshalThrowable(OpenWireFormat wireFormat, Throwable o, DataOutput dataOut) + throws IOException { + dataOut.writeBoolean(o != null); + if (o != null) { + looseMarshalString(o.getClass().getName(), dataOut); + looseMarshalString(o.getMessage(), dataOut); + if (wireFormat.isStackTraceEnabled()) { + StackTraceElement[] stackTrace = o.getStackTrace(); + dataOut.writeShort(stackTrace.length); + for (int i = 0; i < stackTrace.length; i++) { + StackTraceElement element = stackTrace[i]; + looseMarshalString(element.getClassName(), dataOut); + looseMarshalString(element.getMethodName(), dataOut); + looseMarshalString(element.getFileName(), dataOut); + dataOut.writeInt(element.getLineNumber()); + } + looseMarshalThrowable(wireFormat, o.getCause(), dataOut); + } + } + } + + protected String looseUnmarshalString(DataInput dataIn) throws IOException { + if (dataIn.readBoolean()) { + return dataIn.readUTF(); + } else { + return null; + } + } + + protected void looseMarshalString(String value, DataOutput dataOut) throws IOException { + dataOut.writeBoolean(value != null); + if (value != null) { + dataOut.writeUTF(value); + } + } + + protected void looseMarshalObjectArray(OpenWireFormat wireFormat, DataStructure[] objects, + DataOutput dataOut) throws IOException { + dataOut.writeBoolean(objects != null); + if (objects != null) { + dataOut.writeShort(objects.length); + for (int i = 0; i < objects.length; i++) { + looseMarshalNestedObject(wireFormat, objects[i], dataOut); + } + } + } + + protected void looseMarshalConstByteArray(OpenWireFormat wireFormat, byte[] data, DataOutput dataOut, + int i) throws IOException { + dataOut.write(data, 0, i); + } + + protected byte[] looseUnmarshalConstByteArray(DataInput dataIn, int i) throws IOException { + byte data[] = new byte[i]; + dataIn.readFully(data); + return data; + } + + protected void looseMarshalByteArray(OpenWireFormat wireFormat, byte[] data, DataOutput dataOut) + throws IOException { + dataOut.writeBoolean(data != null); + if (data != null) { + dataOut.writeInt(data.length); + dataOut.write(data); + } + } + + protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException { + byte rc[] = null; + if (dataIn.readBoolean()) { + int size = dataIn.readInt(); + rc = new byte[size]; + dataIn.readFully(rc); + } + return rc; + } + + protected void looseMarshalByteSequence(OpenWireFormat wireFormat, ByteSequence data, DataOutput dataOut) + throws IOException { + dataOut.writeBoolean(data != null); + if (data != null) { + dataOut.writeInt(data.getLength()); + dataOut.write(data.getData(), data.getOffset(), data.getLength()); + } + } + + protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException { + ByteSequence rc = null; + if (dataIn.readBoolean()) { + int size = dataIn.readInt(); + byte[] t = new byte[size]; + dataIn.readFully(t); + rc = new ByteSequence(t, 0, size); + } + return rc; + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerIdMarshaller.java new file mode 100644 index 0000000000..ac05dbcb81 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerIdMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for BrokerIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class BrokerIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return BrokerId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new BrokerId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + BrokerId info = (BrokerId)o; + info.setValue(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + BrokerId info = (BrokerId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getValue(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + BrokerId info = (BrokerId)o; + tightMarshalString2(info.getValue(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + BrokerId info = (BrokerId)o; + info.setValue(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + BrokerId info = (BrokerId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getValue(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerInfoMarshaller.java new file mode 100644 index 0000000000..4117792904 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BrokerInfoMarshaller.java @@ -0,0 +1,206 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for BrokerInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class BrokerInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return BrokerInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new BrokerInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + BrokerInfo info = (BrokerInfo)o; + info.setBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setBrokerURL(tightUnmarshalString(dataIn, bs)); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerInfo) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setPeerBrokerInfos(value); + } + else { + info.setPeerBrokerInfos(null); + } + info.setBrokerName(tightUnmarshalString(dataIn, bs)); + info.setSlaveBroker(bs.readBoolean()); + info.setMasterBroker(bs.readBoolean()); + info.setFaultTolerantConfiguration(bs.readBoolean()); + info.setDuplexConnection(bs.readBoolean()); + info.setNetworkConnection(bs.readBoolean()); + info.setConnectionId(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setBrokerUploadUrl(tightUnmarshalString(dataIn, bs)); + info.setNetworkProperties(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + BrokerInfo info = (BrokerInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getBrokerId(), bs); + rc += tightMarshalString1(info.getBrokerURL(), bs); + rc += tightMarshalObjectArray1(wireFormat, info.getPeerBrokerInfos(), bs); + rc += tightMarshalString1(info.getBrokerName(), bs); + bs.writeBoolean(info.isSlaveBroker()); + bs.writeBoolean(info.isMasterBroker()); + bs.writeBoolean(info.isFaultTolerantConfiguration()); + bs.writeBoolean(info.isDuplexConnection()); + bs.writeBoolean(info.isNetworkConnection()); + rc+=tightMarshalLong1(wireFormat, info.getConnectionId(), bs); + rc += tightMarshalString1(info.getBrokerUploadUrl(), bs); + rc += tightMarshalString1(info.getNetworkProperties(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + BrokerInfo info = (BrokerInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getBrokerId(), dataOut, bs); + tightMarshalString2(info.getBrokerURL(), dataOut, bs); + tightMarshalObjectArray2(wireFormat, info.getPeerBrokerInfos(), dataOut, bs); + tightMarshalString2(info.getBrokerName(), dataOut, bs); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + tightMarshalLong2(wireFormat, info.getConnectionId(), dataOut, bs); + tightMarshalString2(info.getBrokerUploadUrl(), dataOut, bs); + tightMarshalString2(info.getNetworkProperties(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + BrokerInfo info = (BrokerInfo)o; + info.setBrokerId((org.apache.activemq.command.BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setBrokerURL(looseUnmarshalString(dataIn)); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerInfo) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setPeerBrokerInfos(value); + } + else { + info.setPeerBrokerInfos(null); + } + info.setBrokerName(looseUnmarshalString(dataIn)); + info.setSlaveBroker(dataIn.readBoolean()); + info.setMasterBroker(dataIn.readBoolean()); + info.setFaultTolerantConfiguration(dataIn.readBoolean()); + info.setDuplexConnection(dataIn.readBoolean()); + info.setNetworkConnection(dataIn.readBoolean()); + info.setConnectionId(looseUnmarshalLong(wireFormat, dataIn)); + info.setBrokerUploadUrl(looseUnmarshalString(dataIn)); + info.setNetworkProperties(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + BrokerInfo info = (BrokerInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getBrokerId(), dataOut); + looseMarshalString(info.getBrokerURL(), dataOut); + looseMarshalObjectArray(wireFormat, info.getPeerBrokerInfos(), dataOut); + looseMarshalString(info.getBrokerName(), dataOut); + dataOut.writeBoolean(info.isSlaveBroker()); + dataOut.writeBoolean(info.isMasterBroker()); + dataOut.writeBoolean(info.isFaultTolerantConfiguration()); + dataOut.writeBoolean(info.isDuplexConnection()); + dataOut.writeBoolean(info.isNetworkConnection()); + looseMarshalLong(wireFormat, info.getConnectionId(), dataOut); + looseMarshalString(info.getBrokerUploadUrl(), dataOut); + looseMarshalString(info.getNetworkProperties(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java new file mode 100644 index 0000000000..2a5a0cc0c5 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java @@ -0,0 +1,169 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConnectionControlMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConnectionControlMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConnectionControl.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConnectionControl(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConnectionControl info = (ConnectionControl)o; + info.setClose(bs.readBoolean()); + info.setExit(bs.readBoolean()); + info.setFaultTolerant(bs.readBoolean()); + info.setResume(bs.readBoolean()); + info.setSuspend(bs.readBoolean()); + info.setConnectedBrokers(tightUnmarshalString(dataIn, bs)); + info.setReconnectTo(tightUnmarshalString(dataIn, bs)); + info.setRebalanceConnection(bs.readBoolean()); + info.setToken(tightUnmarshalByteArray(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConnectionControl info = (ConnectionControl)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + bs.writeBoolean(info.isClose()); + bs.writeBoolean(info.isExit()); + bs.writeBoolean(info.isFaultTolerant()); + bs.writeBoolean(info.isResume()); + bs.writeBoolean(info.isSuspend()); + rc += tightMarshalString1(info.getConnectedBrokers(), bs); + rc += tightMarshalString1(info.getReconnectTo(), bs); + bs.writeBoolean(info.isRebalanceConnection()); + rc += tightMarshalByteArray1(info.getToken(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConnectionControl info = (ConnectionControl)o; + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + tightMarshalString2(info.getConnectedBrokers(), dataOut, bs); + tightMarshalString2(info.getReconnectTo(), dataOut, bs); + bs.readBoolean(); + tightMarshalByteArray2(info.getToken(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConnectionControl info = (ConnectionControl)o; + info.setClose(dataIn.readBoolean()); + info.setExit(dataIn.readBoolean()); + info.setFaultTolerant(dataIn.readBoolean()); + info.setResume(dataIn.readBoolean()); + info.setSuspend(dataIn.readBoolean()); + info.setConnectedBrokers(looseUnmarshalString(dataIn)); + info.setReconnectTo(looseUnmarshalString(dataIn)); + info.setRebalanceConnection(dataIn.readBoolean()); + info.setToken(looseUnmarshalByteArray(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConnectionControl info = (ConnectionControl)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeBoolean(info.isClose()); + dataOut.writeBoolean(info.isExit()); + dataOut.writeBoolean(info.isFaultTolerant()); + dataOut.writeBoolean(info.isResume()); + dataOut.writeBoolean(info.isSuspend()); + looseMarshalString(info.getConnectedBrokers(), dataOut); + looseMarshalString(info.getReconnectTo(), dataOut); + dataOut.writeBoolean(info.isRebalanceConnection()); + looseMarshalByteArray(wireFormat, info.getToken(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionErrorMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionErrorMarshaller.java new file mode 100644 index 0000000000..0d50525ee0 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionErrorMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConnectionErrorMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConnectionErrorMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConnectionError.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConnectionError(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConnectionError info = (ConnectionError)o; + info.setException((java.lang.Throwable) tightUnmarsalThrowable(wireFormat, dataIn, bs)); + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConnectionError info = (ConnectionError)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalThrowable1(wireFormat, info.getException(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConnectionError info = (ConnectionError)o; + tightMarshalThrowable2(wireFormat, info.getException(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConnectionError info = (ConnectionError)o; + info.setException((java.lang.Throwable) looseUnmarsalThrowable(wireFormat, dataIn)); + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConnectionError info = (ConnectionError)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalThrowable(wireFormat, info.getException(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionIdMarshaller.java new file mode 100644 index 0000000000..3e9116ba32 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionIdMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConnectionIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConnectionIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConnectionId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConnectionId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConnectionId info = (ConnectionId)o; + info.setValue(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConnectionId info = (ConnectionId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getValue(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConnectionId info = (ConnectionId)o; + tightMarshalString2(info.getValue(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConnectionId info = (ConnectionId)o; + info.setValue(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConnectionId info = (ConnectionId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getValue(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionInfoMarshaller.java new file mode 100644 index 0000000000..35b73bcf92 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionInfoMarshaller.java @@ -0,0 +1,201 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConnectionInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConnectionInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConnectionInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConnectionInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConnectionInfo info = (ConnectionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setClientId(tightUnmarshalString(dataIn, bs)); + info.setPassword(tightUnmarshalString(dataIn, bs)); + info.setUserName(tightUnmarshalString(dataIn, bs)); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setBrokerMasterConnector(bs.readBoolean()); + info.setManageable(bs.readBoolean()); + info.setClientMaster(bs.readBoolean()); + info.setFaultTolerant(bs.readBoolean()); + info.setFailoverReconnect(bs.readBoolean()); + info.setClientIp(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConnectionInfo info = (ConnectionInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + rc += tightMarshalString1(info.getClientId(), bs); + rc += tightMarshalString1(info.getPassword(), bs); + rc += tightMarshalString1(info.getUserName(), bs); + rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); + bs.writeBoolean(info.isBrokerMasterConnector()); + bs.writeBoolean(info.isManageable()); + bs.writeBoolean(info.isClientMaster()); + bs.writeBoolean(info.isFaultTolerant()); + bs.writeBoolean(info.isFailoverReconnect()); + rc += tightMarshalString1(info.getClientIp(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConnectionInfo info = (ConnectionInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + tightMarshalString2(info.getClientId(), dataOut, bs); + tightMarshalString2(info.getPassword(), dataOut, bs); + tightMarshalString2(info.getUserName(), dataOut, bs); + tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + tightMarshalString2(info.getClientIp(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConnectionInfo info = (ConnectionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setClientId(looseUnmarshalString(dataIn)); + info.setPassword(looseUnmarshalString(dataIn)); + info.setUserName(looseUnmarshalString(dataIn)); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setBrokerMasterConnector(dataIn.readBoolean()); + info.setManageable(dataIn.readBoolean()); + info.setClientMaster(dataIn.readBoolean()); + info.setFaultTolerant(dataIn.readBoolean()); + info.setFailoverReconnect(dataIn.readBoolean()); + info.setClientIp(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConnectionInfo info = (ConnectionInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + looseMarshalString(info.getClientId(), dataOut); + looseMarshalString(info.getPassword(), dataOut); + looseMarshalString(info.getUserName(), dataOut); + looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); + dataOut.writeBoolean(info.isBrokerMasterConnector()); + dataOut.writeBoolean(info.isManageable()); + dataOut.writeBoolean(info.isClientMaster()); + dataOut.writeBoolean(info.isFaultTolerant()); + dataOut.writeBoolean(info.isFailoverReconnect()); + looseMarshalString(info.getClientIp(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerControlMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerControlMarshaller.java new file mode 100644 index 0000000000..3408d1de5f --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerControlMarshaller.java @@ -0,0 +1,158 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConsumerControlMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConsumerControlMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConsumerControl.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConsumerControl(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConsumerControl info = (ConsumerControl)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setClose(bs.readBoolean()); + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setPrefetch(dataIn.readInt()); + info.setFlush(bs.readBoolean()); + info.setStart(bs.readBoolean()); + info.setStop(bs.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConsumerControl info = (ConsumerControl)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + bs.writeBoolean(info.isClose()); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + bs.writeBoolean(info.isFlush()); + bs.writeBoolean(info.isStart()); + bs.writeBoolean(info.isStop()); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConsumerControl info = (ConsumerControl)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + bs.readBoolean(); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + dataOut.writeInt(info.getPrefetch()); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConsumerControl info = (ConsumerControl)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setClose(dataIn.readBoolean()); + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setPrefetch(dataIn.readInt()); + info.setFlush(dataIn.readBoolean()); + info.setStart(dataIn.readBoolean()); + info.setStop(dataIn.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConsumerControl info = (ConsumerControl)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + dataOut.writeBoolean(info.isClose()); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + dataOut.writeInt(info.getPrefetch()); + dataOut.writeBoolean(info.isFlush()); + dataOut.writeBoolean(info.isStart()); + dataOut.writeBoolean(info.isStop()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerIdMarshaller.java new file mode 100644 index 0000000000..d7cae0d526 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerIdMarshaller.java @@ -0,0 +1,139 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConsumerIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConsumerIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConsumerId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConsumerId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConsumerId info = (ConsumerId)o; + info.setConnectionId(tightUnmarshalString(dataIn, bs)); + info.setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConsumerId info = (ConsumerId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getConnectionId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getSessionId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getValue(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConsumerId info = (ConsumerId)o; + tightMarshalString2(info.getConnectionId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getSessionId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getValue(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConsumerId info = (ConsumerId)o; + info.setConnectionId(looseUnmarshalString(dataIn)); + info.setSessionId(looseUnmarshalLong(wireFormat, dataIn)); + info.setValue(looseUnmarshalLong(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConsumerId info = (ConsumerId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getConnectionId(), dataOut); + looseMarshalLong(wireFormat, info.getSessionId(), dataOut); + looseMarshalLong(wireFormat, info.getValue(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerInfoMarshaller.java new file mode 100644 index 0000000000..26cf14cdb0 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConsumerInfoMarshaller.java @@ -0,0 +1,260 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ConsumerInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ConsumerInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ConsumerInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ConsumerInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ConsumerInfo info = (ConsumerInfo)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setBrowser(bs.readBoolean()); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setPrefetchSize(dataIn.readInt()); + info.setMaximumPendingMessageLimit(dataIn.readInt()); + info.setDispatchAsync(bs.readBoolean()); + info.setSelector(tightUnmarshalString(dataIn, bs)); + info.setClientId(tightUnmarshalString(dataIn, bs)); + info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); + info.setNoLocal(bs.readBoolean()); + info.setExclusive(bs.readBoolean()); + info.setRetroactive(bs.readBoolean()); + info.setPriority(dataIn.readByte()); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setNetworkSubscription(bs.readBoolean()); + info.setOptimizedAcknowledge(bs.readBoolean()); + info.setNoRangeAcks(bs.readBoolean()); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.ConsumerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setNetworkConsumerPath(value); + } + else { + info.setNetworkConsumerPath(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ConsumerInfo info = (ConsumerInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + bs.writeBoolean(info.isBrowser()); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + bs.writeBoolean(info.isDispatchAsync()); + rc += tightMarshalString1(info.getSelector(), bs); + rc += tightMarshalString1(info.getClientId(), bs); + rc += tightMarshalString1(info.getSubscriptionName(), bs); + bs.writeBoolean(info.isNoLocal()); + bs.writeBoolean(info.isExclusive()); + bs.writeBoolean(info.isRetroactive()); + rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getAdditionalPredicate(), bs); + bs.writeBoolean(info.isNetworkSubscription()); + bs.writeBoolean(info.isOptimizedAcknowledge()); + bs.writeBoolean(info.isNoRangeAcks()); + rc += tightMarshalObjectArray1(wireFormat, info.getNetworkConsumerPath(), bs); + + return rc + 9; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ConsumerInfo info = (ConsumerInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + bs.readBoolean(); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + dataOut.writeInt(info.getPrefetchSize()); + dataOut.writeInt(info.getMaximumPendingMessageLimit()); + bs.readBoolean(); + tightMarshalString2(info.getSelector(), dataOut, bs); + tightMarshalString2(info.getClientId(), dataOut, bs); + tightMarshalString2(info.getSubscriptionName(), dataOut, bs); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + dataOut.writeByte(info.getPriority()); + tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut, bs); + bs.readBoolean(); + bs.readBoolean(); + bs.readBoolean(); + tightMarshalObjectArray2(wireFormat, info.getNetworkConsumerPath(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ConsumerInfo info = (ConsumerInfo)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setBrowser(dataIn.readBoolean()); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setPrefetchSize(dataIn.readInt()); + info.setMaximumPendingMessageLimit(dataIn.readInt()); + info.setDispatchAsync(dataIn.readBoolean()); + info.setSelector(looseUnmarshalString(dataIn)); + info.setClientId(looseUnmarshalString(dataIn)); + info.setSubscriptionName(looseUnmarshalString(dataIn)); + info.setNoLocal(dataIn.readBoolean()); + info.setExclusive(dataIn.readBoolean()); + info.setRetroactive(dataIn.readBoolean()); + info.setPriority(dataIn.readByte()); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setNetworkSubscription(dataIn.readBoolean()); + info.setOptimizedAcknowledge(dataIn.readBoolean()); + info.setNoRangeAcks(dataIn.readBoolean()); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.ConsumerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setNetworkConsumerPath(value); + } + else { + info.setNetworkConsumerPath(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ConsumerInfo info = (ConsumerInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + dataOut.writeBoolean(info.isBrowser()); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + dataOut.writeInt(info.getPrefetchSize()); + dataOut.writeInt(info.getMaximumPendingMessageLimit()); + dataOut.writeBoolean(info.isDispatchAsync()); + looseMarshalString(info.getSelector(), dataOut); + looseMarshalString(info.getClientId(), dataOut); + looseMarshalString(info.getSubscriptionName(), dataOut); + dataOut.writeBoolean(info.isNoLocal()); + dataOut.writeBoolean(info.isExclusive()); + dataOut.writeBoolean(info.isRetroactive()); + dataOut.writeByte(info.getPriority()); + looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut); + dataOut.writeBoolean(info.isNetworkSubscription()); + dataOut.writeBoolean(info.isOptimizedAcknowledge()); + dataOut.writeBoolean(info.isNoRangeAcks()); + looseMarshalObjectArray(wireFormat, info.getNetworkConsumerPath(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ControlCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ControlCommandMarshaller.java new file mode 100644 index 0000000000..b811995cdf --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ControlCommandMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ControlCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ControlCommandMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ControlCommand.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ControlCommand(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ControlCommand info = (ControlCommand)o; + info.setCommand(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ControlCommand info = (ControlCommand)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getCommand(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ControlCommand info = (ControlCommand)o; + tightMarshalString2(info.getCommand(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ControlCommand info = (ControlCommand)o; + info.setCommand(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ControlCommand info = (ControlCommand)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getCommand(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataArrayResponseMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataArrayResponseMarshaller.java new file mode 100644 index 0000000000..867b8bbe4b --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataArrayResponseMarshaller.java @@ -0,0 +1,151 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for DataArrayResponseMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class DataArrayResponseMarshaller extends ResponseMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return DataArrayResponse.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new DataArrayResponse(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + DataArrayResponse info = (DataArrayResponse)o; + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.DataStructure value[] = new org.apache.activemq.command.DataStructure[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setData(value); + } + else { + info.setData(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + DataArrayResponse info = (DataArrayResponse)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalObjectArray1(wireFormat, info.getData(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + DataArrayResponse info = (DataArrayResponse)o; + tightMarshalObjectArray2(wireFormat, info.getData(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + DataArrayResponse info = (DataArrayResponse)o; + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.DataStructure value[] = new org.apache.activemq.command.DataStructure[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setData(value); + } + else { + info.setData(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + DataArrayResponse info = (DataArrayResponse)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalObjectArray(wireFormat, info.getData(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataResponseMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataResponseMarshaller.java new file mode 100644 index 0000000000..b62d537983 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DataResponseMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for DataResponseMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class DataResponseMarshaller extends ResponseMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return DataResponse.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new DataResponse(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + DataResponse info = (DataResponse)o; + info.setData((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + DataResponse info = (DataResponse)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getData(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + DataResponse info = (DataResponse)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getData(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + DataResponse info = (DataResponse)o; + info.setData((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + DataResponse info = (DataResponse)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getData(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DestinationInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DestinationInfoMarshaller.java new file mode 100644 index 0000000000..81686767f2 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DestinationInfoMarshaller.java @@ -0,0 +1,170 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for DestinationInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class DestinationInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return DestinationInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new DestinationInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + DestinationInfo info = (DestinationInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setOperationType(dataIn.readByte()); + info.setTimeout(tightUnmarshalLong(wireFormat, dataIn, bs)); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + DestinationInfo info = (DestinationInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc+=tightMarshalLong1(wireFormat, info.getTimeout(), bs); + rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); + + return rc + 1; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + DestinationInfo info = (DestinationInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + dataOut.writeByte(info.getOperationType()); + tightMarshalLong2(wireFormat, info.getTimeout(), dataOut, bs); + tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + DestinationInfo info = (DestinationInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setOperationType(dataIn.readByte()); + info.setTimeout(looseUnmarshalLong(wireFormat, dataIn)); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + DestinationInfo info = (DestinationInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + dataOut.writeByte(info.getOperationType()); + looseMarshalLong(wireFormat, info.getTimeout(), dataOut); + looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DiscoveryEventMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DiscoveryEventMarshaller.java new file mode 100644 index 0000000000..167a53226c --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/DiscoveryEventMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for DiscoveryEventMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class DiscoveryEventMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return DiscoveryEvent.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new DiscoveryEvent(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + DiscoveryEvent info = (DiscoveryEvent)o; + info.setServiceName(tightUnmarshalString(dataIn, bs)); + info.setBrokerName(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + DiscoveryEvent info = (DiscoveryEvent)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getServiceName(), bs); + rc += tightMarshalString1(info.getBrokerName(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + DiscoveryEvent info = (DiscoveryEvent)o; + tightMarshalString2(info.getServiceName(), dataOut, bs); + tightMarshalString2(info.getBrokerName(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + DiscoveryEvent info = (DiscoveryEvent)o; + info.setServiceName(looseUnmarshalString(dataIn)); + info.setBrokerName(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + DiscoveryEvent info = (DiscoveryEvent)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getServiceName(), dataOut); + looseMarshalString(info.getBrokerName(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ExceptionResponseMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ExceptionResponseMarshaller.java new file mode 100644 index 0000000000..2a5f6f7a18 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ExceptionResponseMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ExceptionResponseMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ExceptionResponseMarshaller extends ResponseMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ExceptionResponse.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ExceptionResponse(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ExceptionResponse info = (ExceptionResponse)o; + info.setException((java.lang.Throwable) tightUnmarsalThrowable(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ExceptionResponse info = (ExceptionResponse)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalThrowable1(wireFormat, info.getException(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ExceptionResponse info = (ExceptionResponse)o; + tightMarshalThrowable2(wireFormat, info.getException(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ExceptionResponse info = (ExceptionResponse)o; + info.setException((java.lang.Throwable) looseUnmarsalThrowable(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ExceptionResponse info = (ExceptionResponse)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalThrowable(wireFormat, info.getException(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/FlushCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/FlushCommandMarshaller.java new file mode 100644 index 0000000000..0dffa30f8b --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/FlushCommandMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for FlushCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class FlushCommandMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return FlushCommand.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new FlushCommand(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/IntegerResponseMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/IntegerResponseMarshaller.java new file mode 100644 index 0000000000..419b6d14ef --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/IntegerResponseMarshaller.java @@ -0,0 +1,128 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for IntegerResponseMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class IntegerResponseMarshaller extends ResponseMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return IntegerResponse.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new IntegerResponse(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + IntegerResponse info = (IntegerResponse)o; + info.setResult(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + IntegerResponse info = (IntegerResponse)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + IntegerResponse info = (IntegerResponse)o; + dataOut.writeInt(info.getResult()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + IntegerResponse info = (IntegerResponse)o; + info.setResult(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + IntegerResponse info = (IntegerResponse)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getResult()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalQueueAckMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalQueueAckMarshaller.java new file mode 100644 index 0000000000..d2e5397dba --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalQueueAckMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for JournalQueueAckMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class JournalQueueAckMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return JournalQueueAck.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new JournalQueueAck(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + JournalQueueAck info = (JournalQueueAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setMessageAck((org.apache.activemq.command.MessageAck) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + JournalQueueAck info = (JournalQueueAck)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageAck(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + JournalQueueAck info = (JournalQueueAck)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageAck(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + JournalQueueAck info = (JournalQueueAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setMessageAck((org.apache.activemq.command.MessageAck) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + JournalQueueAck info = (JournalQueueAck)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageAck(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTopicAckMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTopicAckMarshaller.java new file mode 100644 index 0000000000..d0bab04cf0 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTopicAckMarshaller.java @@ -0,0 +1,154 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for JournalTopicAckMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class JournalTopicAckMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return JournalTopicAck.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new JournalTopicAck(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + JournalTopicAck info = (JournalTopicAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setMessageSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setSubscritionName(tightUnmarshalString(dataIn, bs)); + info.setClientId(tightUnmarshalString(dataIn, bs)); + info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + JournalTopicAck info = (JournalTopicAck)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getMessageSequenceId(), bs); + rc += tightMarshalString1(info.getSubscritionName(), bs); + rc += tightMarshalString1(info.getClientId(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + JournalTopicAck info = (JournalTopicAck)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getMessageSequenceId(), dataOut, bs); + tightMarshalString2(info.getSubscritionName(), dataOut, bs); + tightMarshalString2(info.getClientId(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + JournalTopicAck info = (JournalTopicAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setMessageSequenceId(looseUnmarshalLong(wireFormat, dataIn)); + info.setSubscritionName(looseUnmarshalString(dataIn)); + info.setClientId(looseUnmarshalString(dataIn)); + info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + JournalTopicAck info = (JournalTopicAck)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut); + looseMarshalLong(wireFormat, info.getMessageSequenceId(), dataOut); + looseMarshalString(info.getSubscritionName(), dataOut); + looseMarshalString(info.getClientId(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTraceMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTraceMarshaller.java new file mode 100644 index 0000000000..542c1423ce --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTraceMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for JournalTraceMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class JournalTraceMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return JournalTrace.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new JournalTrace(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + JournalTrace info = (JournalTrace)o; + info.setMessage(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + JournalTrace info = (JournalTrace)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getMessage(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + JournalTrace info = (JournalTrace)o; + tightMarshalString2(info.getMessage(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + JournalTrace info = (JournalTrace)o; + info.setMessage(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + JournalTrace info = (JournalTrace)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getMessage(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTransactionMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTransactionMarshaller.java new file mode 100644 index 0000000000..9435a2b17e --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/JournalTransactionMarshaller.java @@ -0,0 +1,138 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for JournalTransactionMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class JournalTransactionMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return JournalTransaction.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new JournalTransaction(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + JournalTransaction info = (JournalTransaction)o; + info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setType(dataIn.readByte()); + info.setWasPrepared(bs.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + JournalTransaction info = (JournalTransaction)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); + bs.writeBoolean(info.getWasPrepared()); + + return rc + 1; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + JournalTransaction info = (JournalTransaction)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); + dataOut.writeByte(info.getType()); + bs.readBoolean(); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + JournalTransaction info = (JournalTransaction)o; + info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setType(dataIn.readByte()); + info.setWasPrepared(dataIn.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + JournalTransaction info = (JournalTransaction)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); + dataOut.writeByte(info.getType()); + dataOut.writeBoolean(info.getWasPrepared()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/KeepAliveInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/KeepAliveInfoMarshaller.java new file mode 100644 index 0000000000..a5db7fc24b --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/KeepAliveInfoMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for KeepAliveInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class KeepAliveInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return KeepAliveInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new KeepAliveInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LastPartialCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LastPartialCommandMarshaller.java new file mode 100644 index 0000000000..14232ba562 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LastPartialCommandMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for LastPartialCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class LastPartialCommandMarshaller extends PartialCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return LastPartialCommand.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new LastPartialCommand(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LocalTransactionIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LocalTransactionIdMarshaller.java new file mode 100644 index 0000000000..d3c0f82e39 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/LocalTransactionIdMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for LocalTransactionIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class LocalTransactionIdMarshaller extends TransactionIdMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return LocalTransactionId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new LocalTransactionId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + LocalTransactionId info = (LocalTransactionId)o; + info.setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + LocalTransactionId info = (LocalTransactionId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc+=tightMarshalLong1(wireFormat, info.getValue(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + LocalTransactionId info = (LocalTransactionId)o; + tightMarshalLong2(wireFormat, info.getValue(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + LocalTransactionId info = (LocalTransactionId)o; + info.setValue(looseUnmarshalLong(wireFormat, dataIn)); + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + LocalTransactionId info = (LocalTransactionId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalLong(wireFormat, info.getValue(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MarshallerFactory.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MarshallerFactory.java new file mode 100644 index 0000000000..4ff72b701c --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MarshallerFactory.java @@ -0,0 +1,109 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import org.apache.activemq.openwire.DataStreamMarshaller; +import org.apache.activemq.openwire.OpenWireFormat; + +/** + * MarshallerFactory for Open Wire Format. + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MarshallerFactory { + + /** + * Creates a Map of command type -> Marshallers + */ + static final private DataStreamMarshaller marshaller[] = new DataStreamMarshaller[256]; + static { + + add(new ActiveMQBlobMessageMarshaller()); + add(new ActiveMQBytesMessageMarshaller()); + add(new ActiveMQMapMessageMarshaller()); + add(new ActiveMQMessageMarshaller()); + add(new ActiveMQObjectMessageMarshaller()); + add(new ActiveMQQueueMarshaller()); + add(new ActiveMQStreamMessageMarshaller()); + add(new ActiveMQTempQueueMarshaller()); + add(new ActiveMQTempTopicMarshaller()); + add(new ActiveMQTextMessageMarshaller()); + add(new ActiveMQTopicMarshaller()); + add(new BrokerIdMarshaller()); + add(new BrokerInfoMarshaller()); + add(new ConnectionControlMarshaller()); + add(new ConnectionErrorMarshaller()); + add(new ConnectionIdMarshaller()); + add(new ConnectionInfoMarshaller()); + add(new ConsumerControlMarshaller()); + add(new ConsumerIdMarshaller()); + add(new ConsumerInfoMarshaller()); + add(new ControlCommandMarshaller()); + add(new DataArrayResponseMarshaller()); + add(new DataResponseMarshaller()); + add(new DestinationInfoMarshaller()); + add(new DiscoveryEventMarshaller()); + add(new ExceptionResponseMarshaller()); + add(new FlushCommandMarshaller()); + add(new IntegerResponseMarshaller()); + add(new JournalQueueAckMarshaller()); + add(new JournalTopicAckMarshaller()); + add(new JournalTraceMarshaller()); + add(new JournalTransactionMarshaller()); + add(new KeepAliveInfoMarshaller()); + add(new LastPartialCommandMarshaller()); + add(new LocalTransactionIdMarshaller()); + add(new MessageAckMarshaller()); + add(new MessageDispatchMarshaller()); + add(new MessageDispatchNotificationMarshaller()); + add(new MessageIdMarshaller()); + add(new MessagePullMarshaller()); + add(new NetworkBridgeFilterMarshaller()); + add(new PartialCommandMarshaller()); + add(new ProducerAckMarshaller()); + add(new ProducerIdMarshaller()); + add(new ProducerInfoMarshaller()); + add(new RemoveInfoMarshaller()); + add(new RemoveSubscriptionInfoMarshaller()); + add(new ReplayCommandMarshaller()); + add(new ResponseMarshaller()); + add(new SessionIdMarshaller()); + add(new SessionInfoMarshaller()); + add(new ShutdownInfoMarshaller()); + add(new SubscriptionInfoMarshaller()); + add(new TransactionInfoMarshaller()); + add(new WireFormatInfoMarshaller()); + add(new XATransactionIdMarshaller()); + + } + + static private void add(DataStreamMarshaller dsm) { + marshaller[dsm.getDataStructureType()] = dsm; + } + + static public DataStreamMarshaller[] createMarshallerMap(OpenWireFormat wireFormat) { + return marshaller; + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageAckMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageAckMarshaller.java new file mode 100644 index 0000000000..49339333c7 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageAckMarshaller.java @@ -0,0 +1,162 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessageAckMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MessageAckMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return MessageAck.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new MessageAck(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + MessageAck info = (MessageAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setAckType(dataIn.readByte()); + info.setFirstMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setLastMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setMessageCount(dataIn.readInt()); + info.setPoisonCause((java.lang.Throwable) tightUnmarsalThrowable(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + MessageAck info = (MessageAck)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); + rc += tightMarshalThrowable1(wireFormat, info.getPoisonCause(), bs); + + return rc + 5; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + MessageAck info = (MessageAck)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + dataOut.writeByte(info.getAckType()); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getLastMessageId(), dataOut, bs); + dataOut.writeInt(info.getMessageCount()); + tightMarshalThrowable2(wireFormat, info.getPoisonCause(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + MessageAck info = (MessageAck)o; + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setAckType(dataIn.readByte()); + info.setFirstMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setLastMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setMessageCount(dataIn.readInt()); + info.setPoisonCause((java.lang.Throwable) looseUnmarsalThrowable(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + MessageAck info = (MessageAck)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + dataOut.writeByte(info.getAckType()); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); + dataOut.writeInt(info.getMessageCount()); + looseMarshalThrowable(wireFormat, info.getPoisonCause(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchMarshaller.java new file mode 100644 index 0000000000..d9ac54ff08 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchMarshaller.java @@ -0,0 +1,143 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessageDispatchMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MessageDispatchMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return MessageDispatch.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new MessageDispatch(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + MessageDispatch info = (MessageDispatch)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setMessage((org.apache.activemq.command.Message) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setRedeliveryCounter(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + MessageDispatch info = (MessageDispatch)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + MessageDispatch info = (MessageDispatch)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessage(), dataOut, bs); + dataOut.writeInt(info.getRedeliveryCounter()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + MessageDispatch info = (MessageDispatch)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setMessage((org.apache.activemq.command.Message) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setRedeliveryCounter(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + MessageDispatch info = (MessageDispatch)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); + dataOut.writeInt(info.getRedeliveryCounter()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchNotificationMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchNotificationMarshaller.java new file mode 100644 index 0000000000..d37a213e7d --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageDispatchNotificationMarshaller.java @@ -0,0 +1,144 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessageDispatchNotificationMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MessageDispatchNotificationMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return MessageDispatchNotification.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new MessageDispatchNotification(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + MessageDispatchNotification info = (MessageDispatchNotification)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDeliverySequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + MessageDispatchNotification info = (MessageDispatchNotification)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc+=tightMarshalLong1(wireFormat, info.getDeliverySequenceId(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + MessageDispatchNotification info = (MessageDispatchNotification)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getDeliverySequenceId(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + MessageDispatchNotification info = (MessageDispatchNotification)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDeliverySequenceId(looseUnmarshalLong(wireFormat, dataIn)); + info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + MessageDispatchNotification info = (MessageDispatchNotification)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalLong(wireFormat, info.getDeliverySequenceId(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageIdMarshaller.java new file mode 100644 index 0000000000..7d51527fa9 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageIdMarshaller.java @@ -0,0 +1,144 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessageIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MessageIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return MessageId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new MessageId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + MessageId info = (MessageId)o; + info.setTextView(tightUnmarshalString(dataIn, bs)); + info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setProducerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setBrokerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + MessageId info = (MessageId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getTextView(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getProducerSequenceId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getBrokerSequenceId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + MessageId info = (MessageId)o; + tightMarshalString2(info.getTextView(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getProducerSequenceId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getBrokerSequenceId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + MessageId info = (MessageId)o; + info.setTextView(looseUnmarshalString(dataIn)); + info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setProducerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); + info.setBrokerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + MessageId info = (MessageId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getTextView(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut); + looseMarshalLong(wireFormat, info.getProducerSequenceId(), dataOut); + looseMarshalLong(wireFormat, info.getBrokerSequenceId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java new file mode 100644 index 0000000000..54a99423d1 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java @@ -0,0 +1,316 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessageMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public abstract class MessageMarshaller extends BaseCommandMarshaller { + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + Message info = (Message)o; + + info.beforeUnmarshall(wireFormat); + + info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setGroupID(tightUnmarshalString(dataIn, bs)); + info.setGroupSequence(dataIn.readInt()); + info.setCorrelationId(tightUnmarshalString(dataIn, bs)); + info.setPersistent(bs.readBoolean()); + info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setPriority(dataIn.readByte()); + info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setType(tightUnmarshalString(dataIn, bs)); + info.setContent(tightUnmarshalByteSequence(dataIn, bs)); + info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs)); + info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setCompressed(bs.readBoolean()); + info.setRedeliveryCounter(dataIn.readInt()); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setUserID(tightUnmarshalString(dataIn, bs)); + info.setRecievedByDFBridge(bs.readBoolean()); + info.setDroppable(bs.readBoolean()); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setCluster(value); + } + else { + info.setCluster(null); + } + info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setJMSXGroupFirstForConsumer(bs.readBoolean()); + + info.afterUnmarshall(wireFormat); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + Message info = (Message)o; + + info.beforeMarshall(wireFormat); + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs); + rc += tightMarshalString1(info.getGroupID(), bs); + rc += tightMarshalString1(info.getCorrelationId(), bs); + bs.writeBoolean(info.isPersistent()); + rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs); + rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs); + rc += tightMarshalString1(info.getType(), bs); + rc += tightMarshalByteSequence1(info.getContent(), bs); + rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs); + bs.writeBoolean(info.isCompressed()); + rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); + rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs); + rc += tightMarshalString1(info.getUserID(), bs); + bs.writeBoolean(info.isRecievedByDFBridge()); + bs.writeBoolean(info.isDroppable()); + rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs); + rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs); + rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs); + bs.writeBoolean(info.isJMSXGroupFirstForConsumer()); + + return rc + 9; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + Message info = (Message)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs); + tightMarshalString2(info.getGroupID(), dataOut, bs); + dataOut.writeInt(info.getGroupSequence()); + tightMarshalString2(info.getCorrelationId(), dataOut, bs); + bs.readBoolean(); + tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs); + dataOut.writeByte(info.getPriority()); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs); + tightMarshalString2(info.getType(), dataOut, bs); + tightMarshalByteSequence2(info.getContent(), dataOut, bs); + tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs); + bs.readBoolean(); + dataOut.writeInt(info.getRedeliveryCounter()); + tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs); + tightMarshalString2(info.getUserID(), dataOut, bs); + bs.readBoolean(); + bs.readBoolean(); + tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs); + bs.readBoolean(); + + info.afterMarshall(wireFormat); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + Message info = (Message)o; + + info.beforeUnmarshall(wireFormat); + + info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setGroupID(looseUnmarshalString(dataIn)); + info.setGroupSequence(dataIn.readInt()); + info.setCorrelationId(looseUnmarshalString(dataIn)); + info.setPersistent(dataIn.readBoolean()); + info.setExpiration(looseUnmarshalLong(wireFormat, dataIn)); + info.setPriority(dataIn.readByte()); + info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn)); + info.setType(looseUnmarshalString(dataIn)); + info.setContent(looseUnmarshalByteSequence(dataIn)); + info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn)); + info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setCompressed(dataIn.readBoolean()); + info.setRedeliveryCounter(dataIn.readInt()); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setArrival(looseUnmarshalLong(wireFormat, dataIn)); + info.setUserID(looseUnmarshalString(dataIn)); + info.setRecievedByDFBridge(dataIn.readBoolean()); + info.setDroppable(dataIn.readBoolean()); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setCluster(value); + } + else { + info.setCluster(null); + } + info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn)); + info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn)); + info.setJMSXGroupFirstForConsumer(dataIn.readBoolean()); + + info.afterUnmarshall(wireFormat); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + Message info = (Message)o; + + info.beforeMarshall(wireFormat); + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut); + looseMarshalString(info.getGroupID(), dataOut); + dataOut.writeInt(info.getGroupSequence()); + looseMarshalString(info.getCorrelationId(), dataOut); + dataOut.writeBoolean(info.isPersistent()); + looseMarshalLong(wireFormat, info.getExpiration(), dataOut); + dataOut.writeByte(info.getPriority()); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut); + looseMarshalLong(wireFormat, info.getTimestamp(), dataOut); + looseMarshalString(info.getType(), dataOut); + looseMarshalByteSequence(wireFormat, info.getContent(), dataOut); + looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut); + dataOut.writeBoolean(info.isCompressed()); + dataOut.writeInt(info.getRedeliveryCounter()); + looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); + looseMarshalLong(wireFormat, info.getArrival(), dataOut); + looseMarshalString(info.getUserID(), dataOut); + dataOut.writeBoolean(info.isRecievedByDFBridge()); + dataOut.writeBoolean(info.isDroppable()); + looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut); + looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut); + looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut); + dataOut.writeBoolean(info.isJMSXGroupFirstForConsumer()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessagePullMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessagePullMarshaller.java new file mode 100644 index 0000000000..3ef1cb5d87 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessagePullMarshaller.java @@ -0,0 +1,149 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for MessagePullMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class MessagePullMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return MessagePull.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new MessagePull(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + MessagePull info = (MessagePull)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setTimeout(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setCorrelationId(tightUnmarshalString(dataIn, bs)); + info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + MessagePull info = (MessagePull)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc+=tightMarshalLong1(wireFormat, info.getTimeout(), bs); + rc += tightMarshalString1(info.getCorrelationId(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + MessagePull info = (MessagePull)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getTimeout(), dataOut, bs); + tightMarshalString2(info.getCorrelationId(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + MessagePull info = (MessagePull)o; + info.setConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setTimeout(looseUnmarshalLong(wireFormat, dataIn)); + info.setCorrelationId(looseUnmarshalString(dataIn)); + info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + MessagePull info = (MessagePull)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalLong(wireFormat, info.getTimeout(), dataOut); + looseMarshalString(info.getCorrelationId(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/NetworkBridgeFilterMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/NetworkBridgeFilterMarshaller.java new file mode 100644 index 0000000000..a326d5971e --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/NetworkBridgeFilterMarshaller.java @@ -0,0 +1,137 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for NetworkBridgeFilterMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class NetworkBridgeFilterMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return NetworkBridgeFilter.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new NetworkBridgeFilter(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + NetworkBridgeFilter info = (NetworkBridgeFilter)o; + info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setMessageTTL(dataIn.readInt()); + info.setConsumerTTL(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + NetworkBridgeFilter info = (NetworkBridgeFilter)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getNetworkBrokerId(), bs); + + return rc + 8; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + NetworkBridgeFilter info = (NetworkBridgeFilter)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut, bs); + dataOut.writeInt(info.getMessageTTL()); + dataOut.writeInt(info.getConsumerTTL()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + NetworkBridgeFilter info = (NetworkBridgeFilter)o; + info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setMessageTTL(dataIn.readInt()); + info.setConsumerTTL(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + NetworkBridgeFilter info = (NetworkBridgeFilter)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut); + dataOut.writeInt(info.getMessageTTL()); + dataOut.writeInt(info.getConsumerTTL()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java new file mode 100644 index 0000000000..db480e1ba4 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java @@ -0,0 +1,133 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for PartialCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class PartialCommandMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return PartialCommand.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new PartialCommand(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + PartialCommand info = (PartialCommand)o; + info.setCommandId(dataIn.readInt()); + info.setData(tightUnmarshalByteArray(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + PartialCommand info = (PartialCommand)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalByteArray1(info.getData(), bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + PartialCommand info = (PartialCommand)o; + dataOut.writeInt(info.getCommandId()); + tightMarshalByteArray2(info.getData(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + PartialCommand info = (PartialCommand)o; + info.setCommandId(dataIn.readInt()); + info.setData(looseUnmarshalByteArray(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + PartialCommand info = (PartialCommand)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getCommandId()); + looseMarshalByteArray(wireFormat, info.getData(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerAckMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerAckMarshaller.java new file mode 100644 index 0000000000..f65370ae57 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerAckMarshaller.java @@ -0,0 +1,133 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ProducerAckMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ProducerAckMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ProducerAck.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ProducerAck(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ProducerAck info = (ProducerAck)o; + info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setSize(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ProducerAck info = (ProducerAck)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getProducerId(), bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ProducerAck info = (ProducerAck)o; + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs); + dataOut.writeInt(info.getSize()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ProducerAck info = (ProducerAck)o; + info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setSize(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ProducerAck info = (ProducerAck)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut); + dataOut.writeInt(info.getSize()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerIdMarshaller.java new file mode 100644 index 0000000000..61299d4844 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerIdMarshaller.java @@ -0,0 +1,139 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ProducerIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ProducerIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ProducerId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ProducerId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ProducerId info = (ProducerId)o; + info.setConnectionId(tightUnmarshalString(dataIn, bs)); + info.setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); + info.setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ProducerId info = (ProducerId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getConnectionId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getValue(), bs); + rc+=tightMarshalLong1(wireFormat, info.getSessionId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ProducerId info = (ProducerId)o; + tightMarshalString2(info.getConnectionId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getValue(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getSessionId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ProducerId info = (ProducerId)o; + info.setConnectionId(looseUnmarshalString(dataIn)); + info.setValue(looseUnmarshalLong(wireFormat, dataIn)); + info.setSessionId(looseUnmarshalLong(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ProducerId info = (ProducerId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getConnectionId(), dataOut); + looseMarshalLong(wireFormat, info.getValue(), dataOut); + looseMarshalLong(wireFormat, info.getSessionId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerInfoMarshaller.java new file mode 100644 index 0000000000..792cde9cf4 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ProducerInfoMarshaller.java @@ -0,0 +1,170 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ProducerInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ProducerInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ProducerInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ProducerInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ProducerInfo info = (ProducerInfo)o; + info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + + if (bs.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setDispatchAsync(bs.readBoolean()); + info.setWindowSize(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ProducerInfo info = (ProducerInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); + bs.writeBoolean(info.isDispatchAsync()); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ProducerInfo info = (ProducerInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs); + bs.readBoolean(); + dataOut.writeInt(info.getWindowSize()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ProducerInfo info = (ProducerInfo)o; + info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + + if (dataIn.readBoolean()) { + short size = dataIn.readShort(); + org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; + for( int i=0; i < size; i++ ) { + value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); + } + info.setBrokerPath(value); + } + else { + info.setBrokerPath(null); + } + info.setDispatchAsync(dataIn.readBoolean()); + info.setWindowSize(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ProducerInfo info = (ProducerInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); + dataOut.writeBoolean(info.isDispatchAsync()); + dataOut.writeInt(info.getWindowSize()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveInfoMarshaller.java new file mode 100644 index 0000000000..61c9e4526d --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveInfoMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for RemoveInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class RemoveInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return RemoveInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new RemoveInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + RemoveInfo info = (RemoveInfo)o; + info.setObjectId((org.apache.activemq.command.DataStructure) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setLastDeliveredSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + RemoveInfo info = (RemoveInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getObjectId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getLastDeliveredSequenceId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + RemoveInfo info = (RemoveInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getObjectId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getLastDeliveredSequenceId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + RemoveInfo info = (RemoveInfo)o; + info.setObjectId((org.apache.activemq.command.DataStructure) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setLastDeliveredSequenceId(looseUnmarshalLong(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + RemoveInfo info = (RemoveInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getObjectId(), dataOut); + looseMarshalLong(wireFormat, info.getLastDeliveredSequenceId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveSubscriptionInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveSubscriptionInfoMarshaller.java new file mode 100644 index 0000000000..9d2dfda3be --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/RemoveSubscriptionInfoMarshaller.java @@ -0,0 +1,139 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for RemoveSubscriptionInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class RemoveSubscriptionInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return RemoveSubscriptionInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new RemoveSubscriptionInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setSubcriptionName(tightUnmarshalString(dataIn, bs)); + info.setClientId(tightUnmarshalString(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + rc += tightMarshalString1(info.getSubcriptionName(), bs); + rc += tightMarshalString1(info.getClientId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + tightMarshalString2(info.getSubcriptionName(), dataOut, bs); + tightMarshalString2(info.getClientId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setSubcriptionName(looseUnmarshalString(dataIn)); + info.setClientId(looseUnmarshalString(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + looseMarshalString(info.getSubcriptionName(), dataOut); + looseMarshalString(info.getClientId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ReplayCommandMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ReplayCommandMarshaller.java new file mode 100644 index 0000000000..ccde4f8a53 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ReplayCommandMarshaller.java @@ -0,0 +1,132 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ReplayCommandMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ReplayCommandMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ReplayCommand.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ReplayCommand(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + ReplayCommand info = (ReplayCommand)o; + info.setFirstNakNumber(dataIn.readInt()); + info.setLastNakNumber(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + ReplayCommand info = (ReplayCommand)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 8; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + ReplayCommand info = (ReplayCommand)o; + dataOut.writeInt(info.getFirstNakNumber()); + dataOut.writeInt(info.getLastNakNumber()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + ReplayCommand info = (ReplayCommand)o; + info.setFirstNakNumber(dataIn.readInt()); + info.setLastNakNumber(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + ReplayCommand info = (ReplayCommand)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getFirstNakNumber()); + dataOut.writeInt(info.getLastNakNumber()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ResponseMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ResponseMarshaller.java new file mode 100644 index 0000000000..10c8ba61e3 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ResponseMarshaller.java @@ -0,0 +1,128 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ResponseMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ResponseMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return Response.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new Response(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + Response info = (Response)o; + info.setCorrelationId(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + Response info = (Response)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + Response info = (Response)o; + dataOut.writeInt(info.getCorrelationId()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + Response info = (Response)o; + info.setCorrelationId(dataIn.readInt()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + Response info = (Response)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getCorrelationId()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionIdMarshaller.java new file mode 100644 index 0000000000..6ecaaa916a --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionIdMarshaller.java @@ -0,0 +1,134 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for SessionIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class SessionIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return SessionId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new SessionId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + SessionId info = (SessionId)o; + info.setConnectionId(tightUnmarshalString(dataIn, bs)); + info.setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + SessionId info = (SessionId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getConnectionId(), bs); + rc+=tightMarshalLong1(wireFormat, info.getValue(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + SessionId info = (SessionId)o; + tightMarshalString2(info.getConnectionId(), dataOut, bs); + tightMarshalLong2(wireFormat, info.getValue(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + SessionId info = (SessionId)o; + info.setConnectionId(looseUnmarshalString(dataIn)); + info.setValue(looseUnmarshalLong(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + SessionId info = (SessionId)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getConnectionId(), dataOut); + looseMarshalLong(wireFormat, info.getValue(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionInfoMarshaller.java new file mode 100644 index 0000000000..9aa56d1e22 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SessionInfoMarshaller.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for SessionInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class SessionInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return SessionInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new SessionInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + SessionInfo info = (SessionInfo)o; + info.setSessionId((org.apache.activemq.command.SessionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + SessionInfo info = (SessionInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getSessionId(), bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + SessionInfo info = (SessionInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getSessionId(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + SessionInfo info = (SessionInfo)o; + info.setSessionId((org.apache.activemq.command.SessionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + SessionInfo info = (SessionInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getSessionId(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ShutdownInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ShutdownInfoMarshaller.java new file mode 100644 index 0000000000..fb2494dccf --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ShutdownInfoMarshaller.java @@ -0,0 +1,114 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for ShutdownInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class ShutdownInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return ShutdownInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new ShutdownInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SubscriptionInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SubscriptionInfoMarshaller.java new file mode 100644 index 0000000000..0cf9a3edf8 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/SubscriptionInfoMarshaller.java @@ -0,0 +1,154 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for SubscriptionInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class SubscriptionInfoMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return SubscriptionInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new SubscriptionInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + SubscriptionInfo info = (SubscriptionInfo)o; + info.setClientId(tightUnmarshalString(dataIn, bs)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setSelector(tightUnmarshalString(dataIn, bs)); + info.setSubcriptionName(tightUnmarshalString(dataIn, bs)); + info.setSubscribedDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); + info.setNoLocal(bs.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + SubscriptionInfo info = (SubscriptionInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalString1(info.getClientId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); + rc += tightMarshalString1(info.getSelector(), bs); + rc += tightMarshalString1(info.getSubcriptionName(), bs); + rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getSubscribedDestination(), bs); + bs.writeBoolean(info.isNoLocal()); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + SubscriptionInfo info = (SubscriptionInfo)o; + tightMarshalString2(info.getClientId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); + tightMarshalString2(info.getSelector(), dataOut, bs); + tightMarshalString2(info.getSubcriptionName(), dataOut, bs); + tightMarshalNestedObject2(wireFormat, (DataStructure)info.getSubscribedDestination(), dataOut, bs); + bs.readBoolean(); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + SubscriptionInfo info = (SubscriptionInfo)o; + info.setClientId(looseUnmarshalString(dataIn)); + info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setSelector(looseUnmarshalString(dataIn)); + info.setSubcriptionName(looseUnmarshalString(dataIn)); + info.setSubscribedDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn)); + info.setNoLocal(dataIn.readBoolean()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + SubscriptionInfo info = (SubscriptionInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalString(info.getClientId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); + looseMarshalString(info.getSelector(), dataOut); + looseMarshalString(info.getSubcriptionName(), dataOut); + looseMarshalNestedObject(wireFormat, (DataStructure)info.getSubscribedDestination(), dataOut); + dataOut.writeBoolean(info.isNoLocal()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionIdMarshaller.java new file mode 100644 index 0000000000..9613b076a0 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionIdMarshaller.java @@ -0,0 +1,99 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for TransactionIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public abstract class TransactionIdMarshaller extends BaseDataStreamMarshaller { + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + int rc = super.tightMarshal1(wireFormat, o, bs); + + return rc + 0; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + super.looseMarshal(wireFormat, o, dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionInfoMarshaller.java new file mode 100644 index 0000000000..c762ad9d8f --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/TransactionInfoMarshaller.java @@ -0,0 +1,138 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for TransactionInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class TransactionInfoMarshaller extends BaseCommandMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return TransactionInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new TransactionInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + TransactionInfo info = (TransactionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); + info.setType(dataIn.readByte()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + TransactionInfo info = (TransactionInfo)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); + rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); + + return rc + 1; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + TransactionInfo info = (TransactionInfo)o; + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs); + tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); + dataOut.writeByte(info.getType()); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + TransactionInfo info = (TransactionInfo)o; + info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn)); + info.setType(dataIn.readByte()); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + TransactionInfo info = (TransactionInfo)o; + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); + looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); + dataOut.writeByte(info.getType()); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java new file mode 100644 index 0000000000..ef5e569fd5 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java @@ -0,0 +1,154 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for WireFormatInfoMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return WireFormatInfo.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new WireFormatInfo(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + WireFormatInfo info = (WireFormatInfo)o; + + info.beforeUnmarshall(wireFormat); + + info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8)); + info.setVersion(dataIn.readInt()); + info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs)); + + info.afterUnmarshall(wireFormat); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + WireFormatInfo info = (WireFormatInfo)o; + + info.beforeMarshall(wireFormat); + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8); + rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + WireFormatInfo info = (WireFormatInfo)o; + tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8); + dataOut.writeInt(info.getVersion()); + tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs); + + info.afterMarshall(wireFormat); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + WireFormatInfo info = (WireFormatInfo)o; + + info.beforeUnmarshall(wireFormat); + + info.setMagic(looseUnmarshalConstByteArray(dataIn, 8)); + info.setVersion(dataIn.readInt()); + info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn)); + + info.afterUnmarshall(wireFormat); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + WireFormatInfo info = (WireFormatInfo)o; + + info.beforeMarshall(wireFormat); + + super.looseMarshal(wireFormat, o, dataOut); + looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8); + dataOut.writeInt(info.getVersion()); + looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut); + + } +} diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java new file mode 100644 index 0000000000..ee4b5ecd35 --- /dev/null +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java @@ -0,0 +1,138 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.openwire.v11; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.activemq.openwire.*; +import org.apache.activemq.command.*; + + + +/** + * Marshalling code for Open Wire Format for XATransactionIdMarshaller + * + * + * NOTE!: This file is auto generated - do not modify! + * if you need to make a change, please see the modify the groovy scripts in the + * under src/gram/script and then use maven openwire:generate to regenerate + * this file. + * + * + */ +public class XATransactionIdMarshaller extends TransactionIdMarshaller { + + /** + * Return the type of Data Structure we marshal + * @return short representation of the type data structure + */ + public byte getDataStructureType() { + return XATransactionId.DATA_STRUCTURE_TYPE; + } + + /** + * @return a new object instance + */ + public DataStructure createObject() { + return new XATransactionId(); + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { + super.tightUnmarshal(wireFormat, o, dataIn, bs); + + XATransactionId info = (XATransactionId)o; + info.setFormatId(dataIn.readInt()); + info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs)); + info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { + + XATransactionId info = (XATransactionId)o; + + int rc = super.tightMarshal1(wireFormat, o, bs); + rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs); + rc += tightMarshalByteArray1(info.getBranchQualifier(), bs); + + return rc + 4; + } + + /** + * Write a object instance to data output stream + * + * @param o the instance to be marshaled + * @param dataOut the output stream + * @throws IOException thrown if an error occurs + */ + public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { + super.tightMarshal2(wireFormat, o, dataOut, bs); + + XATransactionId info = (XATransactionId)o; + dataOut.writeInt(info.getFormatId()); + tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs); + tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs); + + } + + /** + * Un-marshal an object instance from the data input stream + * + * @param o the object to un-marshal + * @param dataIn the data input stream to build the object from + * @throws IOException + */ + public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { + super.looseUnmarshal(wireFormat, o, dataIn); + + XATransactionId info = (XATransactionId)o; + info.setFormatId(dataIn.readInt()); + info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn)); + info.setBranchQualifier(looseUnmarshalByteArray(dataIn)); + + } + + + /** + * Write the booleans that this object uses to a BooleanStream + */ + public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { + + XATransactionId info = (XATransactionId)o; + + super.looseMarshal(wireFormat, o, dataOut); + dataOut.writeInt(info.getFormatId()); + looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut); + looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut); + + } +} diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java b/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java index e9a5efec02..2bb47a7c4e 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java @@ -43,11 +43,12 @@ import org.apache.activemq.store.MessageStore; import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.store.TopicMessageStore; import org.apache.activemq.store.TransactionRecoveryListener; -import com.fasterxml.jackson.databind.ObjectMapper; import org.fusesource.hawtbuf.AsciiBuffer; import org.fusesource.hawtbuf.DataByteArrayOutputStream; import org.fusesource.hawtbuf.UTF8Buffer; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * @author Hiram Chirino */ @@ -189,6 +190,7 @@ public class StoreExporter { if (sub.getSelector() != null) { jsonMap.put("selector", sub.getSelector()); } + jsonMap.put("noLocal", sub.isNoLocal()); String json = mapper.writeValueAsString(jsonMap); System.out.println(json); diff --git a/activemq-openwire-generator/pom.xml b/activemq-openwire-generator/pom.xml index 5d0c04f41a..0276275837 100644 --- a/activemq-openwire-generator/pom.xml +++ b/activemq-openwire-generator/pom.xml @@ -56,14 +56,14 @@ java.vendor - Sun Microsystems Inc. + Oracle Corporation com.sun tools - 1.4.2 + 1.5 system ${java.home}/../lib/tools.jar diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java index a5233ee14b..416987a19e 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java @@ -59,6 +59,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,11 +75,11 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { private final TestSupport.PersistenceAdapterChoice persistenceAdapterChoice; - @Parameterized.Parameters + @Parameters(name="{0}") public static Collection getTestParameters() { - TestSupport.PersistenceAdapterChoice[] kahaDb = {TestSupport.PersistenceAdapterChoice.KahaDB}; - TestSupport.PersistenceAdapterChoice[] levelDb = {TestSupport.PersistenceAdapterChoice.LevelDB}; - TestSupport.PersistenceAdapterChoice[] mem = {TestSupport.PersistenceAdapterChoice.MEM}; + TestSupport.PersistenceAdapterChoice[] kahaDb = { TestSupport.PersistenceAdapterChoice.KahaDB }; + TestSupport.PersistenceAdapterChoice[] levelDb = { TestSupport.PersistenceAdapterChoice.LevelDB }; + TestSupport.PersistenceAdapterChoice[] mem = { TestSupport.PersistenceAdapterChoice.MEM }; List choices = new ArrayList(); choices.add(kahaDb); choices.add(levelDb); @@ -102,8 +103,8 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { // preload the durable consumers double[] inactiveConsumerStats = produceMessages(destination, 500, 10, session, producer, null); - LOG.info("With inactive consumers: ave: " + inactiveConsumerStats[1] - + ", max: " + inactiveConsumerStats[0] + ", multiplier: " + (inactiveConsumerStats[0]/inactiveConsumerStats[1])); + LOG.info("With inactive consumers: ave: " + inactiveConsumerStats[1] + ", max: " + inactiveConsumerStats[0] + ", multiplier: " + + (inactiveConsumerStats[0] / inactiveConsumerStats[1])); // periodically start a durable sub that has a backlog final int consumersToActivate = 5; @@ -137,9 +138,10 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { double[] statsWithActive = produceMessages(destination, 500, 10, session, producer, addConsumerSignal); - LOG.info(" with concurrent activate, ave: " + statsWithActive[1] + ", max: " + statsWithActive[0] + ", multiplier: " + (statsWithActive[0]/ statsWithActive[1])); + LOG.info(" with concurrent activate, ave: " + statsWithActive[1] + ", max: " + statsWithActive[0] + ", multiplier: " + + (statsWithActive[0] / statsWithActive[1])); - while(consumers.size() < consumersToActivate) { + while (consumers.size() < consumersToActivate) { TimeUnit.SECONDS.sleep(2); } @@ -149,24 +151,18 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { timeToFirstAccumulator += time; LOG.info("Time to first " + time); } - LOG.info("Ave time to first message =" + timeToFirstAccumulator/consumers.size()); + LOG.info("Ave time to first message =" + timeToFirstAccumulator / consumers.size()); for (TimedMessageListener listener : consumers.values()) { LOG.info("Ave batch receipt time: " + listener.waitForReceivedLimit(10000) + " max receipt: " + listener.maxReceiptTime); } - //assertTrue("max (" + statsWithActive[0] + ") within reasonable multiplier of ave (" + statsWithActive[1] + ")", - // statsWithActive[0] < 5 * statsWithActive[1]); - // compare no active to active - LOG.info("Ave send time with active: " + statsWithActive[1] - + " as multiplier of ave with none active: " + inactiveConsumerStats[1] - + ", multiplier=" + (statsWithActive[1]/inactiveConsumerStats[1])); + LOG.info("Ave send time with active: " + statsWithActive[1] + " as multiplier of ave with none active: " + inactiveConsumerStats[1] + ", multiplier=" + + (statsWithActive[1] / inactiveConsumerStats[1])); - assertTrue("Ave send time with active: " + statsWithActive[1] - + " within reasonable multpler of ave with none active: " + inactiveConsumerStats[1] - + ", multiplier " + (statsWithActive[1]/inactiveConsumerStats[1]), - statsWithActive[1] < 15 * inactiveConsumerStats[1]); + assertTrue("Ave send time with active: " + statsWithActive[1] + " within reasonable multpler of ave with none active: " + inactiveConsumerStats[1] + + ", multiplier " + (statsWithActive[1] / inactiveConsumerStats[1]), statsWithActive[1] < 15 * inactiveConsumerStats[1]); } public void x_testSendWithInactiveAndActiveConsumers() throws Exception { @@ -189,12 +185,11 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { double[] withConsumerStats = produceMessages(destination, toSend, numIterations, session, producer, null); - LOG.info("With consumer: " + withConsumerStats[1] + " , with noConsumer: " + noConsumerStats[1] - + ", multiplier: " + (withConsumerStats[1]/noConsumerStats[1])); + LOG.info("With consumer: " + withConsumerStats[1] + " , with noConsumer: " + noConsumerStats[1] + ", multiplier: " + + (withConsumerStats[1] / noConsumerStats[1])); final int reasonableMultiplier = 15; // not so reasonable but improving - assertTrue("max X times as slow with consumer: " + withConsumerStats[1] + ", with no Consumer: " - + noConsumerStats[1] + ", multiplier: " + (withConsumerStats[1]/noConsumerStats[1]), - withConsumerStats[1] < noConsumerStats[1] * reasonableMultiplier); + assertTrue("max X times as slow with consumer: " + withConsumerStats[1] + ", with no Consumer: " + noConsumerStats[1] + ", multiplier: " + + (withConsumerStats[1] / noConsumerStats[1]), withConsumerStats[1] < noConsumerStats[1] * reasonableMultiplier); final int toReceive = toSend * numIterations * consumerCount * 2; Wait.waitFor(new Wait.Condition() { @@ -217,7 +212,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { private void startInactiveConsumers(ConnectionFactory factory, Destination destination) throws Exception { // create off line consumers startConsumers(factory, destination); - for (Connection connection: connections) { + for (Connection connection : connections) { connection.close(); } connections.clear(); @@ -240,7 +235,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { conn.start(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - final TopicSubscriber consumer = sess.createDurableSubscriber((javax.jms.Topic)dest, name); + final TopicSubscriber consumer = sess.createDurableSubscriber((javax.jms.Topic) dest, name); return consumer; } @@ -249,22 +244,18 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { * @return max and ave send time * @throws Exception */ - private double[] produceMessages(Destination destination, - final int toSend, - final int numIterations, - Session session, - MessageProducer producer, - Object addConsumerSignal) throws Exception { + private double[] produceMessages(Destination destination, final int toSend, final int numIterations, Session session, MessageProducer producer, + Object addConsumerSignal) throws Exception { long start; long count = 0; double batchMax = 0, max = 0, sum = 0; - for (int i=0; i - mysql - mysql-connector-java - 5.1.10 - test - - - commons-dbcp - commons-dbcp - 1.2.2 - test - - */ -// } else { - setPersistenceAdapter(brokerService, persistenceAdapterChoice); -// } return brokerService; } @Override protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory( - broker.getTransportConnectors().get(0).getPublishableConnectString()); + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString()); ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy(); prefetchPolicy.setAll(1); factory.setPrefetchPolicy(prefetchPolicy); @@ -420,9 +379,10 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { int priority = 0; try { priority = message.getJMSPriority(); - } catch (JMSException ignored) {} + } catch (JMSException ignored) { + } if (!messageLists.containsKey(priority)) { - MessageIdList perPriorityList = new MessageIdList(); + MessageIdList perPriorityList = new MessageIdList(); perPriorityList.setParent(allMessagesList); messageLists.put(priority, perPriorityList); } @@ -433,7 +393,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { LOG.info("First receipt in " + firstReceipt + "ms"); } else if (count.get() % batchSize == 0) { LOG.info("Consumed " + count.get() + " in " + batchReceiptAccumulator + "ms" + ", priority:" + priority); - batchReceiptAccumulator=0; + batchReceiptAccumulator = 0; } maxReceiptTime = Math.max(maxReceiptTime, duration); receiptAccumulator += duration; @@ -451,7 +411,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { } public long waitForReceivedLimit(long limit) throws Exception { - final long expiry = System.currentTimeMillis() + 30*60*1000; + final long expiry = System.currentTimeMillis() + 30 * 60 * 1000; while (count.get() < limit) { if (System.currentTimeMillis() > expiry) { throw new RuntimeException("Expired waiting for X messages, " + limit); @@ -464,7 +424,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { } } - return receiptAccumulator/(limit/batchSize); + return receiptAccumulator / (limit / batchSize); } private String findFirstMissingMessage() { @@ -476,9 +436,9 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { if (previous == null) { previous = current.copy(); } else { - if (current.getProducerSequenceId() - 1 != previous.getProducerSequenceId() && - current.getProducerSequenceId() - 10 != previous.getProducerSequenceId()) { - return "Missing next after: " + previous + ", got: " + current; + if (current.getProducerSequenceId() - 1 != previous.getProducerSequenceId() + && current.getProducerSequenceId() - 10 != previous.getProducerSequenceId()) { + return "Missing next after: " + previous + ", got: " + current; } else { previous = current.copy(); } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionWithNoLocalTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionWithNoLocalTest.java new file mode 100644 index 0000000000..4ecf811954 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionWithNoLocalTest.java @@ -0,0 +1,345 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.usecases; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.File; + +import javax.jms.Session; +import javax.jms.Topic; +import javax.jms.TopicConnection; +import javax.jms.TopicPublisher; +import javax.jms.TopicSession; +import javax.jms.TopicSubscriber; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.command.CommandTypes; +import org.apache.activemq.store.kahadb.KahaDBStore; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test for spec compliance for durable subscriptions that change the noLocal flag. + */ +public class DurableSubscriptionWithNoLocalTest { + + private static final Logger LOG = LoggerFactory.getLogger(DurableSubscriptionWithNoLocalTest.class); + + private final int MSG_COUNT = 10; + private final String KAHADB_DIRECTORY = "target/activemq-data/"; + + @Rule public TestName name = new TestName(); + + private BrokerService brokerService; + private String connectionUri; + private ActiveMQConnectionFactory factory; + + @Before + public void setUp() throws Exception { + createBroker(true); + } + + @After + public void tearDown() throws Exception { + brokerService.stop(); + brokerService.waitUntilStopped(); + } + + @Ignore("Requires Broker be able to remove and recreate on noLocal change") + @Test(timeout = 60000) + public void testDurableSubWithNoLocalChange() throws Exception { + TopicConnection connection = factory.createTopicConnection(); + + connection.setClientID(getClientId()); + connection.start(); + + TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + Topic topic = session.createTopic(getDestinationName()); + TopicPublisher publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal = true"); + TopicSubscriber subscriber = session.createSubscriber(topic); + TopicSubscriber durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, true); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from non-durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(subscriber.receive(500)); + } + + LOG.info("Attempting to receive messages from (noLocal=true) subscriber"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.debug("Close DurableSubscriber with noLocal=true"); + durableSub.close(); + + LOG.debug("Create DurableSubscriber with noLocal=false"); + durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, false); + + LOG.info("Attempting to receive messages from reconnected (noLocal=false) subscription"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from (noLocal=false) durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(durableSub.receive(500)); + } + + // Should be empty now + assertNull(durableSub.receive(100)); + } + + @Ignore("Requires Broker be able to remove and recreate on noLocal change") + @Test(timeout = 60000) + public void testInvertedDurableSubWithNoLocalChange() throws Exception { + TopicConnection connection = factory.createTopicConnection(); + + connection.setClientID(getClientId()); + connection.start(); + + TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + Topic topic = session.createTopic(getDestinationName()); + TopicPublisher publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal = true"); + TopicSubscriber subscriber = session.createSubscriber(topic); + TopicSubscriber durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, false); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from non-durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(subscriber.receive(500)); + } + + LOG.info("Attempting to receive messages from (noLocal=false) durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(durableSub.receive(500)); + } + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.debug("Close DurableSubscriber with noLocal=true"); + durableSub.close(); + + LOG.debug("Create DurableSubscriber with noLocal=false"); + durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, true); + + LOG.info("Attempting to receive messages from reconnected (noLocal=true) subscription"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from reconnected (noLocal=true) subscription"); + assertNull(durableSub.receive(500)); + + // Should be empty now + assertNull(durableSub.receive(100)); + } + + @Test(timeout = 60000) + public void testDurableSubWithNoLocalChangeAfterRestart() throws Exception { + TopicConnection connection = factory.createTopicConnection(); + + connection.setClientID(getClientId()); + connection.start(); + + TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + Topic topic = session.createTopic(getDestinationName()); + TopicPublisher publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal = true"); + TopicSubscriber subscriber = session.createSubscriber(topic); + TopicSubscriber durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, true); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from non-durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(subscriber.receive(500)); + } + + LOG.info("Attempting to receive messages from (noLocal=true) subscriber"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + tearDown(); + createBroker(false); + + connection = factory.createTopicConnection(); + connection.setClientID(getClientId()); + connection.start(); + + session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + topic = session.createTopic(getDestinationName()); + publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal=false"); + durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, false); + + LOG.info("Attempting to receive messages from reconnected (noLocal=false) subscription"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from (noLocal=false) durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(durableSub.receive(500)); + } + + // Should be empty now + assertNull(durableSub.receive(100)); + } + + @Ignore("Requires Broker be able to remove and recreate on noLocal change") + @Test(timeout = 60000) + public void testInvertedDurableSubWithNoLocalChangeAfterRestart() throws Exception { + TopicConnection connection = factory.createTopicConnection(); + + connection.setClientID(getClientId()); + connection.start(); + + TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + Topic topic = session.createTopic(getDestinationName()); + TopicPublisher publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal = true"); + TopicSubscriber subscriber = session.createSubscriber(topic); + TopicSubscriber durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, false); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from non-durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(subscriber.receive(500)); + } + + LOG.info("Attempting to receive messages from (noLocal=false) durable subscriber"); + for (int i = 0; i < MSG_COUNT; i++) { + assertNotNull(durableSub.receive(500)); + } + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + tearDown(); + createBroker(false); + + connection = factory.createTopicConnection(); + connection.setClientID(getClientId()); + connection.start(); + + session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + topic = session.createTopic(getDestinationName()); + publisher = session.createPublisher(topic); + + LOG.debug("Create DurableSubscriber with noLocal=true"); + durableSub = session.createDurableSubscriber(topic, getSubscriptionName(), null, true); + + LOG.info("Attempting to receive messages from (noLocal=true) subscriber"); + assertNull(durableSub.receive(500)); + + LOG.debug("Sending " + MSG_COUNT + " messages to topic"); + for (int i = 0; i < MSG_COUNT; i++) { + publisher.publish(session.createMessage()); + } + + LOG.info("Attempting to receive messages from (noLocal=true) subscriber"); + assertNull(durableSub.receive(500)); + + // Should be empty now + assertNull(durableSub.receive(100)); + } + + private void createBroker(boolean deleteAllMessages) throws Exception { + KahaDBStore kaha = new KahaDBStore(); + kaha.setDirectory(new File(KAHADB_DIRECTORY + "-" + name.getMethodName())); + + brokerService = new BrokerService(); + brokerService.setPersistent(true); + brokerService.setPersistenceAdapter(kaha); + brokerService.setStoreOpenWireVersion(CommandTypes.PROTOCOL_VERSION); + brokerService.setUseJmx(false); + brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); + TransportConnector connector = brokerService.addConnector("tcp://0.0.0.0:0"); + + brokerService.start(); + brokerService.waitUntilStarted(); + + connectionUri = connector.getPublishableConnectString(); + factory = new ActiveMQConnectionFactory(connectionUri); + } + + private String getDestinationName() { + return name.getMethodName(); + } + + private String getClientId() { + return name.getMethodName() + "-Client"; + } + + private String getSubscriptionName() { + return name.getMethodName() + "-Subscription"; + } +} From cd32c60f39249664a1a3f9ab3db4229af6b9379a Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Thu, 18 Jun 2015 15:00:12 -0400 Subject: [PATCH 34/52] https://issues.apache.org/jira/browse/AMQ-5850 Use JMS Transformer by default for inter-protocol interoperability. --- .../java/org/apache/activemq/transport/amqp/AmqpWireFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpWireFormat.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpWireFormat.java index 5d261f9c85..b5c8f593ae 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpWireFormat.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpWireFormat.java @@ -49,7 +49,7 @@ public class AmqpWireFormat implements WireFormat { private int connectAttemptTimeout = DEFAULT_CONNECTION_TIMEOUT; private int idelTimeout = DEFAULT_IDLE_TIMEOUT; private int producerCredit = DEFAULT_PRODUCER_CREDIT; - private String transformer = InboundTransformer.TRANSFORMER_NATIVE; + private String transformer = InboundTransformer.TRANSFORMER_JMS; private boolean magicRead = false; private ResetListener resetListener; From e3a72cfa1d23d1e3f1ab44ee1d9841cd47ec2f96 Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 18 Jun 2015 16:11:56 +0100 Subject: [PATCH 35/52] add sanity test for masterslave scheme for networkconnectors --- .../ft/QueueMasterSlaveSingleUrlTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java index b7a35f4215..c05f9d90ba 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java @@ -18,11 +18,13 @@ package org.apache.activemq.broker.ft; import java.io.File; import java.net.URI; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.leveldb.LevelDBStore; +import org.apache.activemq.util.Wait; import org.junit.Ignore; @@ -81,4 +83,36 @@ public class QueueMasterSlaveSingleUrlTest extends QueueMasterSlaveTestSupport { }).start(); } + public void testNetworkMasterSlave() throws Exception { + + final BrokerService client = new BrokerService(); + client.setBrokerName("client"); + client.setPersistent(false); + client.getManagementContext().setCreateConnector(false); + client.addNetworkConnector("masterslave:(tcp://localhost:62001,tcp://localhost:62002)"); + client.start(); + try { + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return client.getRegionBroker().getPeerBrokerInfos().length == 1; + } + }); + + assertTrue(!master.isSlave()); + master.stop(); + assertTrue("slave started", slaveStarted.await(60, TimeUnit.SECONDS)); + assertTrue(!slave.get().isSlave()); + + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return client.getRegionBroker().getPeerBrokerInfos().length == 1; + } + }); + } finally { + client.stop(); + } + + } } From da3174cf98c97eb5736b1c1d414e42590a819f15 Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 18 Jun 2015 16:12:57 +0100 Subject: [PATCH 36/52] ensure data dir is empty for test as derby needs clean dir --- .../activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java index aa56862bf1..8a19397ad6 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java @@ -16,12 +16,15 @@ */ package org.apache.activemq.store.jdbc; +import java.io.File; import java.sql.SQLException; import java.util.LinkedList; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.network.NetworkBrokerDetachTest; +import org.apache.activemq.util.IOHelper; import org.apache.derby.jdbc.EmbeddedDataSource; import org.junit.After; +import org.junit.BeforeClass; public class JDBCNetworkBrokerDetachTest extends NetworkBrokerDetachTest { @@ -55,4 +58,9 @@ public class JDBCNetworkBrokerDetachTest extends NetworkBrokerDetachTest { } dataSources.clear(); } + + @BeforeClass + public static void ensureDerbyHasCleanDirectory() throws Exception { + IOHelper.delete(new File(IOHelper.getDefaultDataDirectory())); + } } From b22184ebf65aac8cb27243c48d8dfe8f1881b283 Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 19 Jun 2015 12:34:35 +0100 Subject: [PATCH 37/52] fix intermittent failure with thread accounting test VmTransportNetworkBrokerTest, it did not lie. ci --- .../simple/SimpleDiscoveryAgent.java | 2 +- .../vm/VmTransportNetworkBrokerTest.java | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java b/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java index 726352b7a5..1d05273618 100755 --- a/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java +++ b/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java @@ -131,7 +131,7 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent { public void serviceFailed(DiscoveryEvent devent) throws IOException { final SimpleDiscoveryEvent sevent = (SimpleDiscoveryEvent)devent; - if (sevent.failed.compareAndSet(false, true)) { + if (running.get() && sevent.failed.compareAndSet(false, true)) { listener.onServiceRemove(sevent); taskRunner.execute(new Runnable() { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java index e29c078e16..e837e05c7a 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java @@ -20,8 +20,8 @@ import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import javax.jms.Connection; import junit.framework.TestCase; @@ -31,6 +31,7 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.bugs.embedded.ThreadExplorer; import org.apache.activemq.network.NetworkConnector; +import org.apache.activemq.util.Wait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,13 +43,12 @@ public class VmTransportNetworkBrokerTest extends TestCase { private static final String VM_BROKER_URI = "vm://localhost?create=false"; - CountDownLatch started = new CountDownLatch(1); - CountDownLatch gotConnection = new CountDownLatch(1); - public void testNoThreadLeak() throws Exception { // with VMConnection and simple discovery network connector - int originalThreadCount = Thread.activeCount(); + Thread[] threads = filterDaemonThreads(ThreadExplorer.listThreads()); + final int originalThreadCount = threads.length; + LOG.debug(ThreadExplorer.show("threads at beginning")); BrokerService broker = new BrokerService(); @@ -67,11 +67,11 @@ public class VmTransportNetworkBrokerTest extends TestCase { TimeUnit.SECONDS.sleep(5); int threadCountAfterStart = Thread.activeCount(); - TimeUnit.SECONDS.sleep(30); + TimeUnit.SECONDS.sleep(20); int threadCountAfterSleep = Thread.activeCount(); assertTrue("Threads are leaking: " + ThreadExplorer.show("active sleep") + ", threadCount=" +threadCountAfterStart + " threadCountAfterSleep=" + threadCountAfterSleep, - threadCountAfterSleep < threadCountAfterStart + 8); + threadCountAfterSleep < 2 * threadCountAfterStart); connection.close(); broker.stop(); @@ -92,15 +92,18 @@ public class VmTransportNetworkBrokerTest extends TestCase { broker.stop(); broker.waitUntilStopped(); - // let it settle - TimeUnit.SECONDS.sleep(5); + final AtomicInteger threadCountAfterStop = new AtomicInteger(); + boolean ok = Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + LOG.info(ThreadExplorer.show("active after stop")); + // get final threads but filter out any daemon threads that the JVM may have created. + Thread[] threads = filterDaemonThreads(ThreadExplorer.listThreads()); + threadCountAfterStop.set(threads.length); + return threadCountAfterStop.get() <= originalThreadCount; + } + }); - // get final threads but filter out any daemon threads that the JVM may have created. - Thread[] threads = filterDaemonThreads(ThreadExplorer.listThreads()); - int threadCountAfterStop = threads.length; - - // lets see the thread counts at INFO level so they are always in the test log - LOG.info(ThreadExplorer.show("active after stop")); LOG.info("originalThreadCount=" + originalThreadCount + " threadCountAfterStop=" + threadCountAfterStop); assertTrue("Threads are leaking: " + @@ -108,8 +111,8 @@ public class VmTransportNetworkBrokerTest extends TestCase { ". originalThreadCount=" + originalThreadCount + " threadCountAfterStop=" + - threadCountAfterStop, - threadCountAfterStop <= originalThreadCount); + threadCountAfterStop.get(), + ok); } @@ -142,7 +145,7 @@ public class VmTransportNetworkBrokerTest extends TestCase { Thread thread = threadList.get(i); LOG.debug("Inspecting thread " + thread.getName()); - if (thread.isDaemon()) { + if (thread.isDaemon() && !thread.getName().contains("ActiveMQ")) { LOG.debug("Removing deamon thread."); threadList.remove(thread); Thread.sleep(100); From 1a3ade04140acd7c63e999a9032f8ce1c3b57c2e Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 19 Jun 2015 12:35:44 +0100 Subject: [PATCH 38/52] fix intermittent failure - wait rather than sleep which also speeds up the test run --- .../failover/FailoverClusterTestSupport.java | 40 +++++++++++-------- .../failover/FailoverComplexClusterTest.java | 10 ----- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java index b277636851..c5e9665e22 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java @@ -36,6 +36,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.network.NetworkConnector; +import org.apache.activemq.util.Wait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,26 +50,31 @@ public class FailoverClusterTestSupport extends TestCase { private final Map brokers = new HashMap(); private final List connections = new ArrayList(); - protected void assertClientsConnectedToTwoBrokers() { - Set set = new HashSet(); - for (ActiveMQConnection c : connections) { - if (c.getTransportChannel().getRemoteAddress() != null) { - set.add(c.getTransportChannel().getRemoteAddress()); - } - } - assertTrue("Only 2 connections should be found: " + set, - set.size() == 2); + protected void assertClientsConnectedToTwoBrokers() throws Exception { + assertClientsConnectedToXBrokers(2); } - protected void assertClientsConnectedToThreeBrokers() { - Set set = new HashSet(); - for (ActiveMQConnection c : connections) { - if (c.getTransportChannel().getRemoteAddress() != null) { - set.add(c.getTransportChannel().getRemoteAddress()); + protected void assertClientsConnectedToThreeBrokers() throws Exception { + assertClientsConnectedToXBrokers(3); + } + + protected void assertClientsConnectedToXBrokers(final int x) throws Exception { + final Set set = new HashSet(); + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + set.clear(); + for (ActiveMQConnection c : connections) { + if (c.getTransportChannel().getRemoteAddress() != null) { + set.add(c.getTransportChannel().getRemoteAddress()); + } + } + return set.size() == x; } - } - assertTrue("Only 3 connections should be found: " + set, - set.size() == 3); + }); + + assertTrue("Only " + x + " connections should be found: " + set, + set.size() == x); } protected void assertClientsConnectionsEvenlyDistributed(double minimumPercentage) { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java index 74fc0b549f..a92ceec4f9 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java @@ -147,7 +147,6 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport { setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")"); createClients(); - Thread.sleep(2000); assertClientsConnectedToThreeBrokers(); @@ -155,13 +154,10 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport { getBroker(BROKER_A_NAME).waitUntilStopped(); removeBroker(BROKER_A_NAME); - Thread.sleep(5000); - assertClientsConnectedToTwoBrokers(); createBrokerA(false, null, null, null); getBroker(BROKER_A_NAME).waitUntilStarted(); - Thread.sleep(5000); assertClientsConnectedToThreeBrokers(); } @@ -264,14 +260,11 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport { getBroker(BROKER_C_NAME).waitUntilStopped(); removeBroker(BROKER_C_NAME); - Thread.sleep(5000); - assertClientsConnectedToTwoBrokers(); LOG.info("Recreating BrokerC after stop"); createBrokerC(multi, tcParams, clusterFilter, destinationFilter); getBroker(BROKER_C_NAME).waitUntilStarted(); - Thread.sleep(5000); assertClientsConnectedToThreeBrokers(); } @@ -292,14 +285,11 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport { getBroker(BROKER_C_NAME).waitUntilStopped(); removeBroker(BROKER_C_NAME); - Thread.sleep(5000); - assertClientsConnectedToTwoBrokers(); assertClientsConnectionsEvenlyDistributed(.35); createBrokerC(multi, tcParams, clusterFilter, destinationFilter); getBroker(BROKER_C_NAME).waitUntilStarted(); - Thread.sleep(5000); assertClientsConnectedToThreeBrokers(); assertClientsConnectionsEvenlyDistributed(.20); From f2a335c27d3f7b986877b93a82eca9eb485d8b18 Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 19 Jun 2015 16:08:54 +0100 Subject: [PATCH 39/52] https://issues.apache.org/jira/browse/AMQ-5853 - fix and test, statement was not configurable from xml also so there is no workaround. --- .../activemq/store/jdbc/Statements.java | 23 ++++++-------- .../activemq/store/MessagePriorityTest.java | 31 +++++++++++++++++++ .../store/jdbc/JDBCMessagePriorityTest.java | 1 - 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/Statements.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/Statements.java index 8ee3123ed2..487556297f 100755 --- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/Statements.java +++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/Statements.java @@ -228,6 +228,10 @@ public class Statements { return findAllMessageIdsStatement; } + public void setFindAllMessageIdsStatement(String val) { + findAllMessageIdsStatement = val; + } + public String getFindLastSequenceIdInMsgsStatement() { if (findLastSequenceIdInMsgsStatement == null) { findLastSequenceIdInMsgsStatement = "SELECT MAX(ID) FROM " + getFullMessageTableName(); @@ -331,17 +335,6 @@ public class Statements { return findDurableSubMessagesByPriorityStatement; } - public String findAllDurableSubMessagesStatement() { - if (findAllDurableSubMessagesStatement == null) { - findAllDurableSubMessagesStatement = "SELECT M.ID, M.MSG FROM " + getFullMessageTableName() - + " M, " + getFullAckTableName() + " D " - + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" - + " AND M.CONTAINER=D.CONTAINER AND M.ID > D.LAST_ACKED_ID" - + " ORDER BY M.ID"; - } - return findAllDurableSubMessagesStatement; - } - public String getNextDurableSubscriberMessageStatement() { if (nextDurableSubscriberMessageStatement == null) { nextDurableSubscriberMessageStatement = "SELECT M.ID, M.MSG FROM " @@ -511,12 +504,16 @@ public class Statements { findNextMessagesByPriorityStatement = "SELECT ID, MSG FROM " + getFullMessageTableName() + " WHERE CONTAINER=?" + " AND XID IS NULL" - + " AND ((ID > ? AND ID < ? AND PRIORITY = ?) OR PRIORITY < ?)" + + " AND ((ID > ? AND ID < ? AND PRIORITY >= ?) OR PRIORITY < ?)" + " ORDER BY PRIORITY DESC, ID"; } return findNextMessagesByPriorityStatement; } - + + public void setFindNextMessagesByPriorityStatement(String val) { + findNextMessagesByPriorityStatement = val; + } + /** * @return the lastAckedDurableSubscriberMessageStatement */ diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java index c6b63245ab..63daa00759 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java @@ -94,6 +94,11 @@ abstract public class MessagePriorityTest extends CombinationTestSupport { ignoreExpired.setDeadLetterStrategy(ignoreExpiredStrategy); policyMap.put(new ActiveMQTopic("TEST_CLEANUP_NO_PRIORITY"), ignoreExpired); + PolicyEntry noCachePolicy = new PolicyEntry(); + noCachePolicy.setUseCache(false); + noCachePolicy.setPrioritizedMessages(true); + policyMap.put(new ActiveMQQueue("TEST_LOW_THEN_HIGH_10"), noCachePolicy); + broker.setDestinationPolicy(policyMap); broker.start(); broker.waitUntilStarted(); @@ -584,4 +589,30 @@ abstract public class MessagePriorityTest extends CombinationTestSupport { assertEquals("Message " + i + " has wrong priority", i < 10 ? HIGH_PRI : LOW_PRI, msg.getJMSPriority()); } } + + public void testLowThenHighBatch() throws Exception { + ActiveMQQueue queue = (ActiveMQQueue)sess.createQueue("TEST_LOW_THEN_HIGH_10"); + + ProducerThread producerThread = new ProducerThread(queue, 10, LOW_PRI); + producerThread.run(); + + MessageConsumer queueConsumer = sess.createConsumer(queue); + for (int i = 0; i < 10; i++) { + Message message = queueConsumer.receive(10000); + assertNotNull("expect #" + i, message); + assertEquals("correct priority", LOW_PRI, message.getJMSPriority()); + } + queueConsumer.close(); + + producerThread.priority = HIGH_PRI; + producerThread.run(); + + queueConsumer = sess.createConsumer(queue); + for (int i = 0; i < 10; i++) { + Message message = queueConsumer.receive(10000); + assertNotNull("expect #" + i, message); + assertEquals("correct priority", HIGH_PRI, message.getJMSPriority()); + } + queueConsumer.close(); + } } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java index de171fc2da..2f3f083101 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java @@ -42,7 +42,6 @@ import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.store.MessagePriorityTest; import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.util.Wait; -import org.apache.derby.jdbc.EmbeddedDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From a1062c273f8c02b6b6311397d2c0e4059054a1a8 Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Fri, 12 Jun 2015 13:41:05 +0800 Subject: [PATCH 40/52] https://issues.apache.org/jira/browse/AMQ-5811 Added synchronization blocks around sentitive code to prevent concurrent modification of the HashMap. --- .../activemq/ra/ActiveMQResourceAdapter.java | 14 ++-- .../java/org/apache/activemq/ra/MDBTest.java | 72 +++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java index 9ae948a2d8..8c5d4ca0c0 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java @@ -147,9 +147,11 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement * @see javax.resource.spi.ResourceAdapter#stop() */ public void stop() { - while (endpointWorkers.size() > 0) { - ActiveMQEndpointActivationKey key = endpointWorkers.keySet().iterator().next(); - endpointDeactivation(key.getMessageEndpointFactory(), key.getActivationSpec()); + synchronized (endpointWorkers) { + while (endpointWorkers.size() > 0) { + ActiveMQEndpointActivationKey key = endpointWorkers.keySet().iterator().next(); + endpointDeactivation(key.getMessageEndpointFactory(), key.getActivationSpec()); + } } synchronized( this ) { @@ -205,10 +207,12 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement * javax.resource.spi.ActivationSpec) */ public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec activationSpec) { - if (activationSpec instanceof MessageActivationSpec) { ActiveMQEndpointActivationKey key = new ActiveMQEndpointActivationKey(endpointFactory, (MessageActivationSpec)activationSpec); - ActiveMQEndpointWorker worker = endpointWorkers.remove(key); + ActiveMQEndpointWorker worker = null; + synchronized (endpointWorkers) { + worker = endpointWorkers.remove(key); + } if (worker == null) { // This is weird.. that endpoint was not activated.. oh well.. // this method diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java index af36389fcf..89c80c039e 100644 --- a/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java +++ b/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java @@ -274,6 +274,78 @@ public class MDBTest extends TestCase { } + //https://issues.apache.org/jira/browse/AMQ-5811 + public void testAsyncStop() throws Exception { + for (int repeat = 0; repeat < 10; repeat++) { + ActiveMQResourceAdapter adapter = new ActiveMQResourceAdapter(); + adapter.setServerUrl("vm://localhost?broker.persistent=false"); + adapter.setQueuePrefetch(1); + adapter.start(new StubBootstrapContext()); + + final int num = 20; + MessageEndpointFactory[] endpointFactories = new MessageEndpointFactory[num]; + ActiveMQActivationSpec[] activationSpecs = new ActiveMQActivationSpec[num]; + + for (int i = 0; i < num; i++) { + + final StubMessageEndpoint endpoint = new StubMessageEndpoint() + { + public void onMessage(Message message) + { + super.onMessage(message); + } + }; + + activationSpecs[i] = new ActiveMQActivationSpec(); + activationSpecs[i].setDestinationType(Queue.class.getName()); + activationSpecs[i].setDestination("TEST" + i); + activationSpecs[i].setResourceAdapter(adapter); + activationSpecs[i].validate(); + + endpointFactories[i] = new MessageEndpointFactory() { + public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException { + endpoint.xaresource = resource; + return endpoint; + } + + public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException { + return true; + } + }; + + // Activate an Endpoint + adapter.endpointActivation(endpointFactories[i], activationSpecs[i]); + } + + //spawn num threads to deactivate + Thread[] threads = asyncDeactivate(adapter, endpointFactories, activationSpecs); + for (int i = 0; i < threads.length; i++) { + threads[i].start(); + } + adapter.stop(); + for (int i = 0; i < threads.length; i++) { + threads[i].join(); + } + } + } + + private Thread[] asyncDeactivate(final ActiveMQResourceAdapter adapter, + final MessageEndpointFactory[] endpointFactories, + final ActiveMQActivationSpec[] activationSpecs) { + Thread[] threads = new Thread[endpointFactories.length]; + for (int i = 0; i < threads.length; i++) { + final MessageEndpointFactory endpointFactory = endpointFactories[i]; + final ActiveMQActivationSpec activationSpec = activationSpecs[i]; + + threads[i] = new Thread() { + public void run() { + adapter.endpointDeactivation(endpointFactory, activationSpec); + } + }; + } + return threads; + } + public void testErrorOnNoMessageDeliveryBrokerZeroPrefetchConfig() throws Exception { final BrokerService brokerService = new BrokerService(); From d919db5e3d8f453c173f6ed82b1e0bce3b3df5fb Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 19 Jun 2015 16:28:43 -0400 Subject: [PATCH 41/52] https://issues.apache.org/jira/browse/AMQ-5804 Apply patch from Pavlo Vasylchenko --- .../activemq/transport/http/HttpClientTransport.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java index 435fafec46..4715d022bb 100755 --- a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java @@ -47,6 +47,8 @@ import org.apache.http.client.methods.HttpOptions; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.params.ConnRoutePNames; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.DefaultHttpClient; @@ -325,6 +327,11 @@ public class HttpClientTransport extends HttpTransportSupport { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + if (client.getConnectionManager().getSchemeRegistry().get("http") == null) { + client.getConnectionManager().getSchemeRegistry().register( + new Scheme("http", getProxyPort(), PlainSocketFactory.getSocketFactory())); + } + if(getProxyUser() != null && getProxyPassword() != null) { client.getCredentialsProvider().setCredentials( new AuthScope(getProxyHost(), getProxyPort()), From c8b604314ac78498584edc861ca8f5e49820656a Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 19 Jun 2015 17:56:22 -0400 Subject: [PATCH 42/52] https://issues.apache.org/jira/browse/AMQ-5740 added reset option to clear destination statistics --- .../console/command/PurgeCommand.java | 99 ++++----- .../activemq/console/PurgeCommandTest.java | 188 ++++++++++++++++++ 2 files changed, 240 insertions(+), 47 deletions(-) create mode 100644 activemq-console/src/test/java/org/apache/activemq/console/PurgeCommandTest.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java index 803c30ce1f..0b58c59384 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java @@ -16,48 +16,41 @@ */ package org.apache.activemq.console.command; -import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; -import javax.jms.Destination; -import javax.jms.Message; -import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectInstance; import javax.management.ObjectName; -import javax.management.openmbean.CompositeData; -import javax.management.remote.JMXConnector; import org.apache.activemq.broker.jmx.QueueViewMBean; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.console.util.AmqMessagesUtil; import org.apache.activemq.console.util.JmxMBeansUtil; public class PurgeCommand extends AbstractJmxCommand { protected String[] helpFile = new String[] { "Task Usage: Main purge [browse-options] ", - "Description: Delete selected destination's messages that matches the message selector.", - "", + "Description: Delete selected destination's messages that matches the message selector.", + "", "Purge Options:", " --msgsel Add to the search list messages matched by the query similar to", " the messages selector format.", + " --reset After the purge operation, reset the destination statistics.", " --jmxurl Set the JMX URL to connect to.", - " --pid Set the pid to connect to (only on Sun JVM).", + " --pid Set the pid to connect to (only on Sun JVM).", " --jmxuser Set the JMX user used for authenticating.", " --jmxpassword Set the JMX password used for authenticating.", " --jmxlocal Use the local JMX server instead of a remote one.", " --version Display the version information.", - " -h,-?,--help Display the browse broker help information.", - "", + " -h,-?,--help Display the browse broker help information.", + "", "Examples:", - " Main purge FOO.BAR", + " Main purge FOO.BAR", " - Delete all the messages in queue FOO.BAR", - " Main purge --msgsel \"JMSMessageID='*:10',JMSPriority>5\" FOO.*", + " Main purge --msgsel \"JMSMessageID='*:10',JMSPriority>5\" FOO.*", " - Delete all the messages in the destinations that matches FOO.* and has a JMSMessageID in", " the header field that matches the wildcard *:10, and has a JMSPriority field > 5 in the", " queue FOO.BAR.", @@ -69,6 +62,7 @@ public class PurgeCommand extends AbstractJmxCommand { private final List queryAddObjects = new ArrayList(10); private final List querySubObjects = new ArrayList(10); + private boolean resetStatistics; @Override public String getName() { @@ -83,10 +77,11 @@ public class PurgeCommand extends AbstractJmxCommand { /** * Execute the purge command, which allows you to purge the messages in a * given JMS destination - * + * * @param tokens - command arguments * @throws Exception */ + @Override protected void runTask(List tokens) throws Exception { try { // If there is no queue name specified, let's select all @@ -103,36 +98,40 @@ public class PurgeCommand extends AbstractJmxCommand { if (queryAddObjects.isEmpty()) { purgeQueue(queueName); } else { - - QueueViewMBean proxy = (QueueViewMBean) MBeanServerInvocationHandler. - newProxyInstance(createJmxConnection(), - queueName, - QueueViewMBean.class, - true); + + QueueViewMBean proxy = MBeanServerInvocationHandler. + newProxyInstance(createJmxConnection(), + queueName, + QueueViewMBean.class, + true); int removed = 0; - - // AMQ-3404: We support two syntaxes for the message + + // AMQ-3404: We support two syntaxes for the message // selector query: - // 1) AMQ specific: + // 1) AMQ specific: // "JMSPriority>2,MyHeader='Foo'" // // 2) SQL-92 syntax: // "(JMSPriority>2) AND (MyHeader='Foo')" // // If syntax style 1) is used, the comma separated - // criterias are broken into List elements. - // We then need to construct the SQL-92 query out of + // criterias are broken into List elements. + // We then need to construct the SQL-92 query out of // this list. - + String sqlQuery = null; if (queryAddObjects.size() > 1) { - sqlQuery = convertToSQL92(queryAddObjects); + sqlQuery = convertToSQL92(queryAddObjects); } else { - sqlQuery = queryAddObjects.get(0); + sqlQuery = queryAddObjects.get(0); } removed = proxy.removeMatchingMessages(sqlQuery); context.printInfo("Removed: " + removed + " messages for message selector " + sqlQuery.toString()); + + if (resetStatistics) { + proxy.resetStatistics(); + } } } } @@ -141,38 +140,42 @@ public class PurgeCommand extends AbstractJmxCommand { throw new Exception(e); } } - - + + /** * Purge all the messages in the queue - * + * * @param queue - ObjectName of the queue to purge * @throws Exception */ public void purgeQueue(ObjectName queue) throws Exception { context.printInfo("Purging all messages in queue: " + queue.getKeyProperty("destinationName")); createJmxConnection().invoke(queue, "purge", new Object[] {}, new String[] {}); + if (resetStatistics) { + createJmxConnection().invoke(queue, "resetStatistics", new Object[] {}, new String[] {}); + } } /** * Handle the --msgsel, --xmsgsel. - * + * * @param token - option token to handle * @param tokens - succeeding command arguments * @throws Exception */ + @Override protected void handleOption(String token, List tokens) throws Exception { // If token is an additive message selector option if (token.startsWith("--msgsel")) { // If no message selector is specified, or next token is a new // option - if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) { + if (tokens.isEmpty() || tokens.get(0).startsWith("-")) { context.printException(new IllegalArgumentException("Message selector not specified")); return; } - StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER); + StringTokenizer queryTokens = new StringTokenizer(tokens.remove(0), COMMAND_OPTION_DELIMETER); while (queryTokens.hasMoreTokens()) { queryAddObjects.add(queryTokens.nextToken()); } @@ -181,35 +184,36 @@ public class PurgeCommand extends AbstractJmxCommand { // If no message selector is specified, or next token is a new // option - if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) { + if (tokens.isEmpty() || tokens.get(0).startsWith("-")) { context.printException(new IllegalArgumentException("Message selector not specified")); return; } - StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER); + StringTokenizer queryTokens = new StringTokenizer(tokens.remove(0), COMMAND_OPTION_DELIMETER); while (queryTokens.hasMoreTokens()) { querySubObjects.add(queryTokens.nextToken()); } - + } else if (token.startsWith("--reset")) { + resetStatistics = true; } else { // Let super class handle unknown option super.handleOption(token, tokens); } } - + /** * Converts the message selector as provided on command line - * argument to activem-admin into an SQL-92 conform string. + * argument to activem-admin into an SQL-92 conform string. * E.g. * "JMSMessageID='*:10',JMSPriority>5" - * gets converted into + * gets converted into * "(JMSMessageID='%:10') AND (JMSPriority>5)" - * - * @param tokens - List of message selector query parameters - * @return SQL-92 string of that query. + * + * @param tokens - List of message selector query parameters + * @return SQL-92 string of that query. */ public String convertToSQL92(List tokens) { - String selector = ""; + String selector = ""; // Convert to message selector for (Iterator i = tokens.iterator(); i.hasNext(); ) { @@ -223,11 +227,12 @@ public class PurgeCommand extends AbstractJmxCommand { } return selector; } - + /** * Print the help messages for the browse command */ + @Override protected void printHelp() { context.printHelp(helpFile); } diff --git a/activemq-console/src/test/java/org/apache/activemq/console/PurgeCommandTest.java b/activemq-console/src/test/java/org/apache/activemq/console/PurgeCommandTest.java new file mode 100644 index 0000000000..1ece787f5c --- /dev/null +++ b/activemq-console/src/test/java/org/apache/activemq/console/PurgeCommandTest.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.console; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.util.Arrays; +import java.util.LinkedList; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.broker.jmx.QueueViewMBean; +import org.apache.activemq.console.command.PurgeCommand; +import org.apache.activemq.console.formatter.CommandShellOutputFormatter; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +/** + * Tests for the purge command. + */ +public class PurgeCommandTest { + + private BrokerService brokerService; + private ConnectionFactory factory; + + @Rule public TestName name = new TestName(); + + @Before + public void createBroker() throws Exception { + brokerService = new BrokerService(); + brokerService.getManagementContext().setCreateConnector(false); + brokerService.setPersistent(false); + TransportConnector connector = brokerService.addConnector("tcp://0.0.0.0:0"); + brokerService.start(); + brokerService.waitUntilStarted(); + + factory = new ActiveMQConnectionFactory(connector.getPublishableConnectString()); + } + + @After + public void stopBroker() throws Exception { + if (brokerService != null) { + brokerService.stop(); + } + } + + @Test(timeout = 30000) + public void testPurge() throws Exception { + produce(10); + + QueueViewMBean queueView = getProxyToQueue(getDestinationName()); + assertEquals(10, queueView.getQueueSize()); + + executePurge(getDestinationName()); + + assertEquals(0, queueView.getQueueSize()); + } + + @Test(timeout = 30000) + public void testPurgeWithReset() throws Exception { + produce(20); + consume(10); + + QueueViewMBean queueView = getProxyToQueue(getDestinationName()); + assertEquals(10, queueView.getQueueSize()); + assertEquals(20, queueView.getEnqueueCount()); + assertEquals(10, queueView.getDequeueCount()); + + // Normal purge doesn't change stats. + executePurge(getDestinationName()); + + assertEquals(0, queueView.getQueueSize()); + assertEquals(20, queueView.getEnqueueCount()); + assertEquals(20, queueView.getDequeueCount()); + + // Purge on empty leaves stats alone. + executePurge(getDestinationName()); + + assertEquals(0, queueView.getQueueSize()); + assertEquals(20, queueView.getEnqueueCount()); + assertEquals(20, queueView.getDequeueCount()); + + executePurge("--reset " + getDestinationName()); + + // Purge on empty with reset clears stats. + assertEquals(0, queueView.getQueueSize()); + assertEquals(0, queueView.getEnqueueCount()); + assertEquals(0, queueView.getDequeueCount()); + + produce(20); + consume(10); + + assertEquals(10, queueView.getQueueSize()); + assertEquals(20, queueView.getEnqueueCount()); + assertEquals(10, queueView.getDequeueCount()); + + executePurge("--reset " + getDestinationName()); + + // Purge on non-empty with reset clears stats. + assertEquals(0, queueView.getQueueSize()); + assertEquals(0, queueView.getEnqueueCount()); + assertEquals(0, queueView.getDequeueCount()); + } + + private String getDestinationName() { + return name.getMethodName(); + } + + private String executePurge(String options) throws Exception { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024); + CommandContext context = new CommandContext(); + context.setFormatter(new CommandShellOutputFormatter(byteArrayOutputStream)); + + PurgeCommand purgeCommand = new PurgeCommand(); + purgeCommand.setJmxUseLocal(true); + purgeCommand.setCommandContext(context); + + LinkedList args = new LinkedList<>(); + args.addAll(Arrays.asList(options.split(" "))); + purgeCommand.execute(args); + + return byteArrayOutputStream.toString(); + } + + private QueueViewMBean getProxyToQueue(String name) throws MalformedObjectNameException, JMSException { + ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName="+name); + QueueViewMBean proxy = (QueueViewMBean) brokerService.getManagementContext() + .newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true); + return proxy; + } + + private void produce(int count) throws Exception { + Connection connection = factory.createConnection(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue(getDestinationName()); + MessageProducer producer = session.createProducer(queue); + + for (int i = 0; i < count; ++i) { + producer.send(session.createMessage()); + } + + connection.close(); + } + + private void consume(int count) throws Exception { + Connection connection = factory.createConnection(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue(getDestinationName()); + MessageConsumer consumer = session.createConsumer(queue); + connection.start(); + + for (int i = 0; i < count; ++i) { + assertNotNull(consumer.receive(1000)); + } + + connection.close(); + } +} From 4c0b7ce9b132b297136a3e4c7c5221fcb32427d3 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Mon, 22 Jun 2015 09:14:55 -0400 Subject: [PATCH 43/52] Add some more to the ignore file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4e01cbdd78..ef4f165aea 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,8 @@ activemq-unit-tests/networkedBroker activemq-unit-tests/shared activemq-data activemq-leveldb-store/.cache +activemq-leveldb-store/.cache-main +activemq-leveldb-store/.cache-tests activemq-runtime-config/src/main/resources/activemq.xsd activemq-amqp/amqp-trace.txt data/ From 26eb103b92ea6412a41191cc8105d87f99a20fa5 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 22 Jun 2015 16:37:46 +0100 Subject: [PATCH 44/52] https://issues.apache.org/jira/browse/AMQ-5400 replace throwable with runtime exception --- .../src/main/java/org/apache/activemq/ActiveMQSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java index ec6e1a1819..c96267d8a0 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java @@ -1062,7 +1062,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta } catch (Throwable t) { LOG.debug("Unable to call after delivery", t); afterDeliveryError.set(true); - throw t; + throw new RuntimeException(t); } } } From 37c46b9b42c8e93378afb101815a857d1c86dc4e Mon Sep 17 00:00:00 2001 From: gtully Date: Tue, 23 Jun 2015 11:25:13 +0100 Subject: [PATCH 45/52] https://issues.apache.org/jira/browse/AMQ-5705 - fix test regression. Make PublishedAddressPolicy vm scheme aware so such that is won't attempt a transform --- .../broker/PublishedAddressPolicy.java | 9 +++-- .../vm/VMTransportBrokerNameTest.java | 33 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java b/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java index 9898482a4b..f620185718 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java @@ -22,6 +22,7 @@ import java.net.UnknownHostException; import java.util.HashMap; import java.util.Locale; +import org.apache.activemq.transport.vm.VMTransport; import org.apache.activemq.util.InetAddressUtil; /** @@ -69,6 +70,10 @@ public class PublishedAddressPolicy { } String scheme = connectorURI.getScheme(); + if ("vm".equals(scheme)) { + return connectorURI; + } + String userInfo = getPublishedUserInfoValue(connectorURI.getUserInfo()); String host = getPublishedHostValue(connectorURI.getHost()); int port = connectorURI.getPort(); @@ -193,14 +198,14 @@ public class PublishedAddressPolicy { } /** - * @param publishedHostStrategy the publishedHostStrategy to set + * @param strategy the publishedHostStrategy to set */ public void setPublishedHostStrategy(PublishedHostStrategy strategy) { this.publishedHostStrategy = strategy; } /** - * @param publishedHostStrategy the publishedHostStrategy to set + * @param strategy the publishedHostStrategy to set */ public void setPublishedHostStrategy(String strategy) { this.publishedHostStrategy = PublishedHostStrategy.getValue(strategy); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java index 50a81f66a7..50785daa33 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java @@ -18,19 +18,23 @@ package org.apache.activemq.transport.vm; import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import javax.jms.Connection; -import org.junit.Test; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerRegistry; +import org.apache.activemq.broker.PublishedAddressPolicy; +import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.command.BrokerInfo; import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.TransportFactory; import org.apache.activemq.transport.TransportListener; +import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -59,6 +63,33 @@ public class VMTransportBrokerNameTest { c2.close(); } + @Test + public void testPublishableAddressUri() throws Exception { + + PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy(); + final AtomicReference uriAtomicReference = new AtomicReference<>(); + + TransportConnector dummyTransportConnector = new TransportConnector() { + @Override + public URI getConnectUri() throws IOException, URISyntaxException { + return uriAtomicReference.get(); + } + }; + URI ok = new URI("vm://b1"); + uriAtomicReference.set(ok); + assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector)); + + ok = new URI("vm://b1?async=false"); + uriAtomicReference.set(ok); + assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector)); + + + URI badHost = new URI("vm://b1_11"); + uriAtomicReference.set(badHost); + assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector)); + + } + @Test public void testBrokerInfoReceiptClientAsync() throws Exception { From 97b0619b26947c9170230e6969df13116f4a2463 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Tue, 23 Jun 2015 16:14:31 +0200 Subject: [PATCH 46/52] [AMQ-5858] add import package --- activemq-web-console/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/activemq-web-console/pom.xml b/activemq-web-console/pom.xml index 4bdbe51400..4223feac5a 100755 --- a/activemq-web-console/pom.xml +++ b/activemq-web-console/pom.xml @@ -131,6 +131,7 @@ org.xml.sax, org.xml.sax.helpers, + javax.xml.bind, javax.xml.parsers, javax.xml.stream, javax.xml.transform, From f0cb95c79252f6f2ae37ee578ef7fa85ae878fa1 Mon Sep 17 00:00:00 2001 From: Dejan Bosanac Date: Wed, 24 Jun 2015 14:20:10 +0200 Subject: [PATCH 47/52] fix amqp karaf test and re-enable tests in CI --- activemq-karaf-itest/pom.xml | 3 --- .../karaf/itest/ActiveMQAMQPBrokerFeatureTest.java | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/activemq-karaf-itest/pom.xml b/activemq-karaf-itest/pom.xml index b6a0378672..8d6fea659a 100644 --- a/activemq-karaf-itest/pom.xml +++ b/activemq-karaf-itest/pom.xml @@ -236,9 +236,6 @@ on this information to PAX mvn url --> -Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local} - - **/*Test.* - ${project.version} ${karaf-version} diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQAMQPBrokerFeatureTest.java b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQAMQPBrokerFeatureTest.java index f9ecba0016..59ce4db654 100644 --- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQAMQPBrokerFeatureTest.java +++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQAMQPBrokerFeatureTest.java @@ -27,6 +27,10 @@ import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; +import java.util.concurrent.Callable; + +import static org.junit.Assert.assertTrue; + @RunWith(PaxExam.class) public class ActiveMQAMQPBrokerFeatureTest extends ActiveMQBrokerFeatureTest { private static final Integer AMQP_PORT = 61636; @@ -49,6 +53,15 @@ public class ActiveMQAMQPBrokerFeatureTest extends ActiveMQBrokerFeatureTest { @Override protected Connection getConnection() throws Throwable { + withinReason(new Callable() { + @Override + public Boolean call() throws Exception { + assertTrue("qpid jms client bundle installed", verifyBundleInstalled("qpid-jms-client")); + return true; + } + }); + + String amqpURI = "amqp://localhost:" + AMQP_PORT; JmsConnectionFactory factory = new JmsConnectionFactory(amqpURI); From 97cd60fb7e2d96f7fb5d2916df04eba6252d1fc9 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Tue, 23 Jun 2015 14:54:06 +0200 Subject: [PATCH 48/52] [AMQ-5821] Use wiring to check for extensions This closes #119 --- .../apache/activemq/util/osgi/Activator.java | 72 ++++++++++++++----- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/util/osgi/Activator.java b/activemq-broker/src/main/java/org/apache/activemq/util/osgi/Activator.java index 9674ab482f..80a143157f 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/util/osgi/Activator.java +++ b/activemq-broker/src/main/java/org/apache/activemq/util/osgi/Activator.java @@ -16,14 +16,18 @@ */ package org.apache.activemq.util.osgi; +import static org.osgi.framework.wiring.BundleRevision.PACKAGE_NAMESPACE; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Properties; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -38,6 +42,9 @@ import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.SynchronousBundleListener; +import org.osgi.framework.wiring.BundleCapability; +import org.osgi.framework.wiring.BundleWire; +import org.osgi.framework.wiring.BundleWiring; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,9 +57,10 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob private static final Logger LOG = LoggerFactory.getLogger(Activator.class); - private final ConcurrentMap serviceCache = new ConcurrentHashMap(); + private final ConcurrentMap> serviceCache = new ConcurrentHashMap>(); private final ConcurrentMap bundleWrappers = new ConcurrentHashMap(); private BundleContext bundleContext; + private Set packageCapabilities = new HashSet(); // ================================================================ // BundleActivator interface impl @@ -67,6 +75,9 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob debug("activating"); this.bundleContext = bundleContext; + + cachePackageCapabilities(Service.class, Transport.class, DiscoveryAgent.class, PersistenceAdapter.class); + debug("checking existing bundles"); bundleContext.addBundleListener(this); for (Bundle bundle : bundleContext.getBundles()) { @@ -78,6 +89,27 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob debug("activated"); } + /** + * Caches the package capabilities that are needed for a set of interface classes + * + * @param classes interfaces we want to track + */ + private void cachePackageCapabilities(Class ... classes) { + BundleWiring ourWiring = bundleContext.getBundle().adapt(BundleWiring.class); + Set packageNames = new HashSet(); + for (Class clazz: classes) { + packageNames.add(clazz.getPackage().getName()); + } + + List ourExports = ourWiring.getCapabilities(PACKAGE_NAMESPACE); + for (BundleCapability ourExport : ourExports) { + String ourPkgName = (String) ourExport.getAttributes().get(PACKAGE_NAMESPACE); + if (packageNames.contains(ourPkgName)) { + packageCapabilities.add(ourExport); + } + } + } + @Override public synchronized void stop(BundleContext bundleContext) throws Exception { @@ -105,11 +137,14 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob protected void register(final Bundle bundle) { debug("checking bundle " + bundle.getBundleId()); - if( !isImportingUs(bundle) ) { - debug("The bundle does not import us: "+ bundle.getBundleId()); - return; + if (isOurBundle(bundle) || isImportingUs(bundle) ) { + debug("Registering bundle for extension resolution: "+ bundle.getBundleId()); + bundleWrappers.put(bundle.getBundleId(), new BundleWrapper(bundle)); } - bundleWrappers.put(bundle.getBundleId(), new BundleWrapper(bundle)); + } + + private boolean isOurBundle(final Bundle bundle) { + return bundle.getBundleId() == bundleContext.getBundle().getBundleId(); } /** @@ -137,7 +172,7 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob @Override public Object create(String path) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException { - Class clazz = serviceCache.get(path); + Class clazz = serviceCache.get(path); if (clazz == null) { StringBuffer warnings = new StringBuffer(); // We need to look for a bundle that has that class. @@ -205,19 +240,22 @@ public class Activator implements BundleActivator, SynchronousBundleListener, Ob } } + /** + * We consider a bundle to be a candidate for objects if it imports at least + * one of the packages of our interfaces + * + * @param bundle + * @return + */ private boolean isImportingUs(Bundle bundle) { - return isImportingClass(bundle, Service.class) - || isImportingClass(bundle, Transport.class) - || isImportingClass(bundle, DiscoveryAgent.class) - || isImportingClass(bundle, PersistenceAdapter.class); - } - - private boolean isImportingClass(Bundle bundle, Class clazz) { - try { - return bundle.loadClass(clazz.getName())==clazz; - } catch (ClassNotFoundException e) { - return false; + BundleWiring wiring = bundle.adapt(BundleWiring.class); + List imports = wiring.getRequiredWires(PACKAGE_NAMESPACE); + for (BundleWire importWire : imports) { + if (packageCapabilities.contains(importWire.getCapability())) { + return true; + } } + return false; } private static class BundleWrapper { From b6fea83126a5d0a7a99f9a6054e3eff17b40ff80 Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 25 Jun 2015 12:49:22 +0100 Subject: [PATCH 49/52] https://issues.apache.org/jira/browse/AMQ-5863 - fix and test - sequenceId state in messageid needs to be cleared before doing a store --- .../apache/activemq/broker/region/Queue.java | 1 + .../apache/activemq/util/BrokerSupport.java | 1 - .../activemq/store/kahadb/KahaDBStore.java | 1 - .../bugs/AMQ5863CompositePublishTest.java | 113 ++++++++++++++++++ 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java index 232a7bae78..af61e1919e 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java @@ -824,6 +824,7 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index try { message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); if (store != null && message.isPersistent()) { + message.getMessageId().setFutureOrSequenceLong(null); try { if (messages.isCacheEnabled()) { result = store.asyncAddQueueMessage(context, message, isOptimizeStorage()); diff --git a/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java b/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java index ca19b8bbd1..f3f3b78544 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java +++ b/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java @@ -55,7 +55,6 @@ public final class BrokerSupport { message.setDestination(deadLetterDestination); message.setTransactionId(null); message.setMemoryUsage(null); - message.getMessageId().setFutureOrSequenceLong(null); message.setRedeliveryCounter(0); boolean originalFlowControl = context.isProducerFlowControl(); try { diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java index 7e06a574b7..8ceef360a4 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java @@ -375,7 +375,6 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter { result.aquireLocks(); addQueueTask(this, result); if (indexListener != null) { - // allow concurrent dispatch by setting entry locator, indexListener.onAdd(new IndexListener.MessageContext(context, message, null)); } return future; diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java new file mode 100644 index 0000000000..615f3e562e --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java @@ -0,0 +1,113 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.bugs; + +import java.util.Arrays; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.Session; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.TestSupport; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQQueue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import static org.junit.Assert.assertNotNull; + +@RunWith(Parameterized.class) +public class AMQ5863CompositePublishTest { + static Logger LOG = LoggerFactory.getLogger(AMQ5863CompositePublishTest.class); + String brokerUrl; + BrokerService brokerService; + + @Parameterized.Parameter(0) + public TestSupport.PersistenceAdapterChoice persistenceAdapterChoice = TestSupport.PersistenceAdapterChoice.KahaDB; + + @Parameterized.Parameters(name = "#store:{0}") + public static Iterable parameters() { + return Arrays.asList(new Object[][]{ + {TestSupport.PersistenceAdapterChoice.KahaDB}, + {TestSupport.PersistenceAdapterChoice.LevelDB}, + {TestSupport.PersistenceAdapterChoice.JDBC} + }); + } + + @Before + public void startBroker() throws Exception { + brokerService = new BrokerService(); + TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice); + brokerService.setDeleteAllMessagesOnStartup(true); + brokerService.setUseJmx(false); + brokerService.setAdvisorySupport(false); + + PolicyMap policyMap = new PolicyMap(); + PolicyEntry defaultEntry = new PolicyEntry(); + defaultEntry.setUseCache(false); + defaultEntry.setExpireMessagesPeriod(0); + policyMap.setDefaultEntry(defaultEntry); + brokerService.setDestinationPolicy(policyMap); + + TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0"); + brokerService.start(); + brokerUrl = transportConnector.getPublishableConnectString(); + } + + @After + public void stopBroker() throws Exception { + if (brokerService != null) { + brokerService.stop(); + } + } + + @Test + public void test() throws Exception { + + ActiveMQQueue compositeSendTo = new ActiveMQQueue("one,two,three"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl); + connectionFactory.setWatchTopicAdvisories(false); + + Connection connection = connectionFactory.createConnection(); + connection.start(); + + try { + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + session.createProducer(compositeSendTo).send(session.createTextMessage("Bing")); + + for (ActiveMQDestination dest : compositeSendTo.getCompositeDestinations()) { + Message message = session.createConsumer(dest).receive(5000); + LOG.info("From: " + dest + ", " + message.getJMSDestination()); + assertNotNull("got message from: " + dest, message); + } + + } finally { + connection.close(); + } + } + +} From 2c53dbcc634920b42ab19a02a183219e58f1ecac Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 25 Jun 2015 15:53:45 +0100 Subject: [PATCH 50/52] https://issues.apache.org/jira/browse/AMQ-5864 - fix and test. A replayed update command did not check if already updated --- .../store/kahadb/MessageDatabase.java | 11 +- .../broker/RedeliveryRecoveryTest.java | 139 ++++++++++++++++++ 2 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRecoveryTest.java diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index e86bed090b..0ff203cd54 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -1320,8 +1320,12 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe } metadata.lastUpdate = location; } else { - // If the message ID is indexed, then the broker asked us to store a duplicate before the message was dispatched and acked, we ignore this add attempt - LOG.warn("Duplicate message add attempt rejected. Destination: {}://{}, Message id: {}", command.getDestination().getType(), command.getDestination().getName(), command.getMessageId()); + + MessageKeys messageKeys = sd.orderIndex.get(tx, previous); + if (messageKeys != null && messageKeys.location.compareTo(location) < 0) { + // If the message ID is indexed, then the broker asked us to store a duplicate before the message was dispatched and acked, we ignore this add attempt + LOG.warn("Duplicate message add attempt rejected. Destination: {}://{}, Message id: {}", command.getDestination().getType(), command.getDestination().getName(), command.getMessageId()); + } sd.messageIdIndex.put(tx, command.getMessageId(), previous); sd.locationIndex.remove(tx, location); id = -1; @@ -1365,7 +1369,8 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe new MessageKeys(command.getMessageId(), location) ); sd.locationIndex.put(tx, location, id); - if(previousKeys != null) { + // on first update previous is original location, on recovery/replay it may be the updated location + if(previousKeys != null && !previousKeys.location.equals(location)) { sd.locationIndex.remove(tx, previousKeys.location); } metadata.lastUpdate = location; diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRecoveryTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRecoveryTest.java new file mode 100644 index 0000000000..7a59c06137 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRecoveryTest.java @@ -0,0 +1,139 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.broker; + +import javax.jms.ConnectionFactory; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.junit.After; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class RedeliveryRecoveryTest { + + static final Logger LOG = LoggerFactory.getLogger(RedeliveryRecoveryTest.class); + ActiveMQConnection connection; + BrokerService broker = null; + String queueName = "redeliveryRecoveryQ"; + + @Before + public void setUp() throws Exception { + broker = new BrokerService(); + configureBroker(broker); + broker.setDeleteAllMessagesOnStartup(true); + broker.start(); + } + + @After + public void tearDown() throws Exception { + if (connection != null) { + connection.close(); + } + broker.stop(); + } + + protected void configureBroker(BrokerService broker) throws Exception { + PolicyMap policyMap = new PolicyMap(); + PolicyEntry policy = new PolicyEntry(); + policy.setPersistJMSRedelivered(true); + policyMap.setDefaultEntry(policy); + broker.setDestinationPolicy(policyMap); + KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); + kahaDBPersistenceAdapter.setForceRecoverIndex(true); + broker.addConnector("tcp://0.0.0.0:0"); + } + + @org.junit.Test + public void testValidateRedeliveryFlagAfterRestart() throws Exception { + + ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString() + + "?jms.prefetchPolicy.all=0"); + connection = (ActiveMQConnection) connectionFactory.createConnection(); + connection.start(); + + Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); + Destination destination = session.createQueue(queueName); + populateDestination(1, destination, connection); + MessageConsumer consumer = session.createConsumer(destination); + Message msg = consumer.receive(5000); + LOG.info("got: " + msg); + assertNotNull("got the message", msg); + assertFalse("got the message", msg.getJMSRedelivered()); + consumer.close(); + connection.close(); + + restartBroker(); + + connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString() + + "?jms.prefetchPolicy.all=0"); + connection = (ActiveMQConnection) connectionFactory.createConnection(); + connection.start(); + + session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); + destination = session.createQueue(queueName); + consumer = session.createConsumer(destination); + + msg = consumer.receive(5000); + LOG.info("got: " + msg); + assertNotNull("got the message", msg); + assertTrue("got the message has redelivered flag", msg.getJMSRedelivered()); + + connection.close(); + } + + + private void restartBroker() throws Exception { + broker.stop(); + broker.waitUntilStopped(); + broker = createRestartedBroker(); + broker.start(); + } + + private BrokerService createRestartedBroker() throws Exception { + broker = new BrokerService(); + configureBroker(broker); + return broker; + } + + private void populateDestination(final int nbMessages, final Destination destination, javax.jms.Connection connection) throws JMSException { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(destination); + producer.setDeliveryMode(DeliveryMode.PERSISTENT); + for (int i = 1; i <= nbMessages; i++) { + producer.send(session.createTextMessage("")); + } + producer.close(); + session.close(); + } + +} \ No newline at end of file From 13c471cc11f61a7589315c82597e01228874dfc3 Mon Sep 17 00:00:00 2001 From: Dejan Bosanac Date: Fri, 26 Jun 2015 12:56:27 +0200 Subject: [PATCH 51/52] https://issues.apache.org/jira/browse/AMQ-5656 - add support for selective mbean suppression; refactor a bit so we can support patterns and wildcards --- .../broker/jmx/ManagementContext.java | 30 +++++-------------- .../jmx/SelectiveMBeanRegistrationTest.java | 5 +++- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java index 089e1dff68..b08d53c706 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java @@ -95,7 +95,7 @@ public class ManagementContext implements Service { private boolean allowRemoteAddressInMBeanNames = true; private String brokerName; private String suppressMBean; - private List> suppressMBeanList; + private List suppressMBeanList; public ManagementContext() { this(null); @@ -106,7 +106,7 @@ public class ManagementContext implements Service { } @Override - public void start() throws IOException { + public void start() throws Exception { // lets force the MBeanServer to be created if needed if (started.compareAndSet(false, true)) { @@ -168,27 +168,11 @@ public class ManagementContext implements Service { } } - private void populateMBeanSuppressionMap() { + private void populateMBeanSuppressionMap() throws Exception { if (suppressMBean != null) { suppressMBeanList = new LinkedList<>(); for (String pair : suppressMBean.split(",")) { - final String[] keyValue = pair.split("="); - suppressMBeanList.add(new Map.Entry() { - @Override - public String getKey() { - return keyValue[0]; - } - - @Override - public String getValue() { - return keyValue[1]; - } - - @Override - public String setValue(String value) { - return null; - } - }); + suppressMBeanList.add(new ObjectName(jmxDomainName + ":*," + pair)); } } } @@ -293,7 +277,7 @@ public class ManagementContext implements Service { * * @return the MBeanServer */ - protected MBeanServer getMBeanServer() { + public MBeanServer getMBeanServer() { if (this.beanServer == null) { this.beanServer = findMBeanServer(); } @@ -430,8 +414,8 @@ public class ManagementContext implements Service { private boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { - for (Map.Entry attr : suppressMBeanList) { - if (attr.getValue().equals(name.getKeyProperty(attr.getKey()))) { + for (ObjectName attr : suppressMBeanList) { + if (attr.apply(name)) { result = false; break; } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java index 0f936a3886..834e60c1eb 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java @@ -61,7 +61,7 @@ public class SelectiveMBeanRegistrationTest { ManagementContext managementContext = new ManagementContext(); managementContext.setCreateConnector(false); - managementContext.setSuppressMBean("endpoint=dynamicProducer,endpoint=Consumer"); + managementContext.setSuppressMBean("endpoint=dynamicProducer,endpoint=Consumer,destinationName=ActiveMQ.Advisory.*"); brokerService.setManagementContext(managementContext); brokerService.start(); @@ -111,6 +111,9 @@ public class SelectiveMBeanRegistrationTest { Set mbeans = mbeanServer.queryMBeans(query, null); assertEquals(0, mbeans.size()); + query = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationName=ActiveMQ.Advisory.*,*"); + mbeans = mbeanServer.queryMBeans(query, null); + assertEquals(0, mbeans.size()); } From 002ade79b01db228377c24438bae246690f57b7d Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 26 Jun 2015 14:54:11 +0100 Subject: [PATCH 52/52] https://issues.apache.org/jira/browse/AMQ-5639 - the duplex case needed work. All advisories were being acked async in duplex mode, that code needed to be more selective to forward advisories that dont terminate at the bridge. Fix and test --- .../DemandForwardingBridgeSupport.java | 5 +- .../activemq/command/NetworkBridgeFilter.java | 4 +- .../usecases/AdvisoryViaNetworkTest.java | 77 +++++++++++++++++++ 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java index 8ba1d98401..8e08f951de 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java @@ -619,8 +619,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br LOG.trace("{} duplex command type: {}", configuration.getBrokerName(), command.getDataStructureType()); if (command.isMessage()) { final ActiveMQMessage message = (ActiveMQMessage) command; - if (AdvisorySupport.isConsumerAdvisoryTopic(message.getDestination()) - || AdvisorySupport.isDestinationAdvisoryTopic(message.getDestination())) { + if (NetworkBridgeFilter.isAdvisoryInterpretedByNetworkBridge(message)) { serviceRemoteConsumerAdvisory(message.getDataStructure()); ackAdvisory(message); } else { @@ -989,7 +988,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br configuration.getBrokerName(), remoteBrokerName, (LOG.isTraceEnabled() ? message : message.getMessageId()), md.getConsumerId(), message.getDestination(), Arrays.toString(message.getBrokerPath()), message }); - if (isDuplex() && AdvisorySupport.ADIVSORY_MESSAGE_TYPE.equals(message.getType())) { + if (isDuplex() && NetworkBridgeFilter.isAdvisoryInterpretedByNetworkBridge(message)) { try { // never request b/c they are eventually acked async remoteBroker.oneway(message); diff --git a/activemq-client/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java b/activemq-client/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java index af0c09e753..245c09840e 100644 --- a/activemq-client/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java +++ b/activemq-client/src/main/java/org/apache/activemq/command/NetworkBridgeFilter.java @@ -97,7 +97,7 @@ public class NetworkBridgeFilter implements DataStructure, BooleanExpression { } if (message.isAdvisory()) { - if (consumerInfo != null && consumerInfo.isNetworkSubscription() && advisoryIsInterpretedByNetworkBridge(message)) { + if (consumerInfo != null && consumerInfo.isNetworkSubscription() && isAdvisoryInterpretedByNetworkBridge(message)) { // they will be interpreted by the bridge leading to dup commands if (LOG.isTraceEnabled()) { LOG.trace("not propagating advisory to network sub: " + consumerInfo.getConsumerId() + ", message: "+ message); @@ -124,7 +124,7 @@ public class NetworkBridgeFilter implements DataStructure, BooleanExpression { return true; } - private boolean advisoryIsInterpretedByNetworkBridge(Message message) { + public static boolean isAdvisoryInterpretedByNetworkBridge(Message message) { return AdvisorySupport.isConsumerAdvisoryTopic(message.getDestination()) || AdvisorySupport.isTempDestinationAdvisoryTopic(message.getDestination()); } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryViaNetworkTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryViaNetworkTest.java index aa7d6ee840..ab61709e7e 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryViaNetworkTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryViaNetworkTest.java @@ -17,10 +17,16 @@ package org.apache.activemq.usecases; import java.net.URI; +import java.util.Arrays; import javax.jms.MessageConsumer; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.DestinationInterceptor; import org.apache.activemq.broker.region.RegionBroker; +import org.apache.activemq.broker.region.virtual.CompositeTopic; +import org.apache.activemq.broker.region.virtual.VirtualDestination; +import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor; +import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.BrokerInfo; import org.apache.activemq.network.NetworkConnector; @@ -71,6 +77,33 @@ public class AdvisoryViaNetworkTest extends JmsMultipleBrokersTestSupport { } + public void testAdvisoryForwardingDuplexNC() throws Exception { + ActiveMQTopic advisoryTopic = new ActiveMQTopic("ActiveMQ.Advisory.Producer.Topic.FOO"); + + createBroker("A"); + createBroker("B"); + NetworkConnector networkBridge = bridgeBrokers("A", "B"); + networkBridge.addStaticallyIncludedDestination(advisoryTopic); + networkBridge.setDuplex(true); + startAllBrokers(); + verifyPeerBrokerInfo(brokers.get("A"), 1); + + + MessageConsumer consumerA = createConsumer("A", advisoryTopic); + MessageConsumer consumerB = createConsumer("B", advisoryTopic); + + this.sendMessages("A", new ActiveMQTopic("FOO"), 1); + + MessageIdList messagesA = getConsumerMessages("A", consumerA); + MessageIdList messagesB = getConsumerMessages("B", consumerB); + + LOG.info("consumerA = " + messagesA); + LOG.info("consumerB = " + messagesB); + + messagesA.assertMessagesReceived(2); + messagesB.assertMessagesReceived(2); + } + public void testBridgeRelevantAdvisoryNotAvailable() throws Exception { ActiveMQTopic advisoryTopic = new ActiveMQTopic("ActiveMQ.Advisory.Consumer.Topic.FOO"); createBroker("A"); @@ -97,6 +130,50 @@ public class AdvisoryViaNetworkTest extends JmsMultipleBrokersTestSupport { messagesB.assertMessagesReceived(0); } + public void testAdvisoryViaVirtualDest() throws Exception { + ActiveMQQueue advisoryQueue = new ActiveMQQueue("advQ"); + createBroker("A"); + + // convert advisories into advQ that cross the network bridge + CompositeTopic compositeTopic = new CompositeTopic(); + compositeTopic.setName("ActiveMQ.Advisory.Connection"); + compositeTopic.setForwardOnly(false); + compositeTopic.setForwardTo(Arrays.asList(advisoryQueue)); + VirtualDestinationInterceptor virtualDestinationInterceptor = new VirtualDestinationInterceptor(); + virtualDestinationInterceptor.setVirtualDestinations(new VirtualDestination[]{compositeTopic}); + brokers.get("A").broker.setDestinationInterceptors(new DestinationInterceptor[]{virtualDestinationInterceptor}); + + createBroker("B"); + NetworkConnector networkBridge = bridgeBrokers("A", "B"); + networkBridge.setDuplex(true); + networkBridge.setPrefetchSize(1); // so advisories are acked immediately b/c we check inflight count below + + startAllBrokers(); + verifyPeerBrokerInfo(brokers.get("A"), 1); + verifyPeerBrokerInfo(brokers.get("B"), 1); + + MessageConsumer consumerB = createConsumer("B", advisoryQueue); + + // to make a connection on A + createConsumer("A", new ActiveMQTopic("FOO")); + + MessageIdList messagesB = getConsumerMessages("B", consumerB); + + messagesB.waitForMessagesToArrive(2); + + assertTrue("deq and inflight as expected", Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + RegionBroker regionBroker = (RegionBroker) brokers.get("A").broker.getRegionBroker(); + LOG.info("A Deq:" + regionBroker.getDestinationStatistics().getDequeues().getCount()); + LOG.info("A Inflight:" + regionBroker.getDestinationStatistics().getInflight().getCount()); + return regionBroker.getDestinationStatistics().getDequeues().getCount() > 2 + && regionBroker.getDestinationStatistics().getInflight().getCount() == 0; + } + })); + + } + private void verifyPeerBrokerInfo(BrokerItem brokerItem, final int max) throws Exception { final BrokerService broker = brokerItem.broker; final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();