Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ConsumerInfo


* @version $Revision: 1.8 $
*/
public abstract class TopicMessageStoreTestSupport extends MessageStoreTestSupport {

    public void testDuplicateSubscription() throws Exception {
        ConsumerInfo info = createConsumerInfo();

        // lets change the subscription
        info.setSelector("priority > 3");

        // this should fail as we'll have duplicate consumeres

        try {
            messageContainerManager.addMessageConsumer(client, info);
View Full Code Here


            info.setHostName(IdGenerator.getHostName());
            info.setClientId(brokerClientID);
            info.setStarted(true);
            client.consumeConnectionInfo(info);

            ConsumerInfo consumerInfo = new ConsumerInfo();
            consumerInfo.setDestination(new ActiveMQTopic(">"));
            consumerInfo.setNoLocal(true);
            consumerInfo.setClientId(brokerClientID);
            consumerInfo.setConsumerId(idGenerator.generateId());
            consumerInfo.setId(consumerInfo.getConsumerId());
            consumerInfo.setStarted(true);
            client.consumeConsumerInfo(consumerInfo);

            consumerInfo = new ConsumerInfo();
            consumerInfo.setDestination(new ActiveMQQueue(">"));
            consumerInfo.setNoLocal(true);
            consumerInfo.setClientId(brokerClientID);
            consumerInfo.setConsumerId(idGenerator.generateId());
            consumerInfo.setId(consumerInfo.getConsumerId());
            consumerInfo.setStarted(true);
            client.consumeConsumerInfo(consumerInfo);
        }

        // now lets create a VM channel that the JMS client will use
        // to connect to the embedded brokerConnector
View Full Code Here

    protected ConsumerInfo createConsumer(String subject) {
        return createConsumer(subject, null);
    }

    protected ConsumerInfo createConsumer(String subject, String selector) {
        ConsumerInfo info = new ConsumerInfo();
        info.setConsumerId(idGenerator.generateId());
        info.setDestination(createDestination(subject));
        info.setSelector(selector);
        return info;
    }
View Full Code Here

        }
    }

    protected Subscription createSubscription() throws JMSException {
        DestinationFilter filter = DestinationFilter.parseFilter(destination);
        ConsumerInfo consumerInfo = createConsumerInfo();

        // lets register the subscription with the manager
        messageContainerManager.addMessageConsumer(client, consumerInfo);

        return new DurableTopicSubscription(new DispatcherImpl(), consumerInfo, filter);
View Full Code Here

        return new DurableTopicSubscription(new DispatcherImpl(), consumerInfo, filter);
    }

    protected ConsumerInfo createConsumerInfo() {
        ConsumerInfo answer = new ConsumerInfo();
        answer.setClientId(getClientID());
        answer.setConsumerId(idGenerator.generateId());
        answer.setConsumerName(getConsumerName());
        answer.setDestination(destination);
        answer.setPrefetchNumber(100);
        answer.setSessionId(idGenerator.generateId());
        answer.setStarted(true);
        return answer;
    }
View Full Code Here

    assertTrue(reader.getPacketType()==Packet.CONSUMER_INFO);
  }

  public void testReadPacket()
  {
    ConsumerInfo info = new ConsumerInfo();
    info.setId(this.consumerId);
    info.setConsumerNo(this.consumerNo);
        info.setPrefetchNumber(this.prefetchNumber);
    info.setClientId(this.clientId);
    info.setConsumerName(this.subscriberName);
    info.setSelector(this.selector);
    info.setDestination(this.destination);
    info.setStartTime(this.startTime);
    info.setStarted(this.started);
   
    ConsumerInfoWriter writer = new ConsumerInfoWriter();
    ConsumerInfoReader reader = new ConsumerInfoReader();
    try {
    byte[] data = writer.writePacketToByteArray(info);
    ConsumerInfo testInfo = (ConsumerInfo) reader.readPacketFromByteArray(data);
   
      assertTrue(testInfo.getId().equals(this.consumerId));
      assertTrue(testInfo.getConsumerNo()==this.consumerNo);
            assertTrue(testInfo.getPrefetchNumber() == this.prefetchNumber);
      assertTrue(testInfo.getClientId().equals(this.clientId));
      assertTrue(testInfo.getConsumerName().equals(this.subscriberName));
      assertTrue(testInfo.getSelector().equals(this.selector));
      assertTrue(testInfo.getDestination().equals(this.destination));
      assertTrue(testInfo.getStartTime() == this.startTime);
      assertTrue(testInfo.isStarted()==this.started);
    }catch(Throwable e){
      e.printStackTrace();
      assertTrue(false);
    }
  }
View Full Code Here

    }
  }
 
  public void testTime(){

    ConsumerInfo info = new ConsumerInfo();
    info.setId(this.consumerId);
    info.setConsumerNo(this.consumerNo);
        info.setPrefetchNumber(this.prefetchNumber);
    info.setClientId(this.clientId);
    info.setConsumerName(this.subscriberName);
    info.setSelector(this.selector);
    info.setDestination(this.destination);
    info.setStartTime(this.startTime);
    info.setStarted(this.started);
   
    ConsumerInfoWriter writer = new ConsumerInfoWriter();
    ConsumerInfoReader reader = new ConsumerInfoReader();
    ConsumerInfo testInfo = null;
    try {
      int count = 100000;
      long startTime = System.currentTimeMillis();
      for (int i = 0; i < count; i++){
        byte[] data = writer.writePacketToByteArray(info);
View Full Code Here

                            TransactionInfo info = (TransactionInfo) packet;
                            consumeTransactionInfo(info);
                            break;
                        }
                        case Packet.CONSUMER_INFO : {
                            ConsumerInfo info = (ConsumerInfo) packet;
                            consumeConsumerInfo(info);
                            break;
                        }
                        case Packet.PRODUCER_INFO : {
                            ProducerInfo info = (ProducerInfo) packet;
View Full Code Here

                    // Dispatch any queued
                    log.debug(this + " has started running client version " + info.getClientVersion()
                            + " , wire format = " + info.getWireFormatVersion());
                    //go through consumers and producers - setting their clientId (which might not have been set)
                    for (Iterator i = consumers.iterator();i.hasNext();) {
                        ConsumerInfo ci = (ConsumerInfo) i.next();
                        ci.setClientId(info.getClientId());
                    }
                    for (Iterator i = producers.iterator();i.hasNext();) {
                        ProducerInfo pi = (ProducerInfo) i.next();
                        pi.setClientId(info.getClientId());
                    }
View Full Code Here

        if (!cleanedUp) {
            cleanedUp = true;
            try {
                try {
                    for (Iterator i = consumers.iterator();i.hasNext();) {
                        ConsumerInfo info = (ConsumerInfo) i.next();
                        info.setStarted(false);
                        this.brokerConnector.deregisterMessageConsumer(this, info);
                    }
                    for (Iterator i = producers.iterator();i.hasNext();) {
                        ProducerInfo info = (ProducerInfo) i.next();
                        info.setStarted(false);
                        this.brokerConnector.deregisterMessageProducer(this, info);
                    }
                    for (Iterator i = sessions.iterator();i.hasNext();) {
                        SessionInfo info = (SessionInfo) i.next();
                        info.setStarted(false);
                        this.brokerConnector.deregisterSession(this, info);
                    }
                    for (Iterator i = transactions.iterator();i.hasNext();) {
                        this.brokerConnector.rollbackTransaction(this, i.next().toString());
                    }
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.message.ConsumerInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.