Package net.timewalker.ffmq3.common.message

Examples of net.timewalker.ffmq3.common.message.MapMessageImpl


        }
    }
   
    protected void multiTopicConnectionListenerTest( String testName , CommTestParameters params , DummyMessageFactory msgFactory ) throws Exception
    {
        Topic topic = new TopicRef(params.destinationName);
       
        SynchronizationPoint startSynchro = new SynchronizationPoint();
        TopicConnection[] receiverConnections = new TopicConnection[params.receiverCount];
        for (int n = 0 ; n < receiverConnections.length ; n++)
            receiverConnections[n] = createTopicConnection();
View Full Code Here


          if (timeout == 0)
          {
            if (!connection.isStarted())
              return null;
           
            AbstractMessage message = localQueue.get((LocalSession)session,
                                   transactionSet,
                                                 selector);         
              if (message == null)
                return null;
             
            if (traceEnabled)
                  log.trace(session+" [GET] in "+localQueue+" - "+message);
 
            if (duplicateRequired)
              message = MessageTools.duplicate(message);
              message.markAsReadOnly();
             
              return message;
          }
   
          // Wait loop
          long now = System.currentTimeMillis();
          long startTime = now;
         
          // Passive wait
          while (!closed && (timeout < 0 || (now - startTime < timeout)))
          {
            // Don't do anything if connection is not started
          if (connection.isStarted())
          {
                  // Try obtaining something from target queue
            AbstractMessage message = localQueue.get((LocalSession)session,
                                                 transactionSet,
                                                 selector);
                if (message != null)
                {
                    if (traceEnabled)
                        log.trace(session+" [GET] in "+localQueue+" - "+message);
                   
                    if (duplicateRequired)
                  message = MessageTools.duplicate(message);
                  message.markAsReadOnly();
                 
                  return message;
                }
          }
             
View Full Code Here

        synchronized (this)
      {
            // Push up to 'prefetchCapacity' messages to the remote consumer
          while (prefetchCapacity > 0)
          {         
            AbstractMessage message = receiveFromDestination(0, false);
            if (message != null)
            {
                count++;
              prefetchCapacity--;
              notificationProxy.addNotification(id,message,prefetchCapacity);
View Full Code Here

        if (messages != null)
        {
            // Dispatch to session
            for(int n=0;n<messages.size();n++)
            {
                AbstractMessage msg = (AbstractMessage)messages.get(n);
                localSession.dispatch(msg);
            }
        }
       
        // Commit session
View Full Code Here

    }
   
    private PutResponse processPut( PutQuery query ) throws JMSException
    {
        LocalSession session = lookupSession(query);
        AbstractMessage msg = query.getMessage();
       
        // Dispatch to session
        session.dispatch(msg);
    
        return new PutResponse();
View Full Code Here

        if (messages != null)
        {
            // Dispatch to session
            for(int n=0;n<messages.size();n++)
            {
                AbstractMessage msg = (AbstractMessage)messages.get(n);
                session.dispatch(msg);
            }
        }
    
        return new MultiplePutResponse();
View Full Code Here

        return msg;
    }
   
    public static MapMessageImpl createMapMessage( int size ) throws JMSException
    {
        MapMessageImpl msg = new MapMessageImpl();
        setDummyProperties(msg);
       
        msg.setBoolean("boolean", true);
        msg.setString("string", "foobar");
        msg.setChar("char", 'c');
        msg.setByte("byte", (byte)1);
        msg.setShort("short", (short)2);
        msg.setInt("int", 3);
        msg.setLong("long", 4);
        msg.setFloat("float", 1.23f);
        msg.setDouble("double", 4.56);
        msg.setBytes("bytearray", createDummyByteArray(size));
       
        return msg;
    }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.jms.Session#createMapMessage()
     */
    public final MapMessage createMapMessage() throws JMSException
    {
        return new MapMessageImpl();
    }
View Full Code Here

    assertEquals("foobar",msg.getString("prop"));
  }
 
  public void testNumericStringConversion() throws Exception
  {
    MapMessageImpl msg;
   
    // Boolean
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertFalse(msg.getBoolean("prop"));
   
    // Byte
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals((byte)123,msg.getByte("prop"));
   
    // Short
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals(123,msg.getShort("prop"));
   
    // Char
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    try { msg.getChar("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals("123",msg.getString("prop"));
   
    // Int
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals(123,msg.getInt("prop"));
   
    // Long
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals(123,msg.getLong("prop"));
   
    // Float
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals(123,msg.getFloat("prop"),0);
   
    // Double
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals(123,msg.getDouble("prop"),0);
   
    // String
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    assertEquals("123",msg.getString("prop"));
   
    // Bytes
    msg = new MapMessageImpl();
    msg.setString("prop","123");
    msg.markAsReadOnly();
    try { msg.getBytes("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals("123",msg.getString("prop"));
  }
 
View Full Code Here

    assertEquals("123",msg.getString("prop"));
  }
 
  public void testBytesConversion() throws Exception
  {
    MapMessageImpl msg;
   
    byte[] dummy = { (byte)1 , (byte)2 , (byte)3 };
   
    // Boolean
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getBoolean("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Byte
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getByte("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Short
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getShort("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Char
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getChar("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Int
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getInt("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Long
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getLong("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Float
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getFloat("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Double
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getDouble("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(3,msg.getBytes("prop").length);
   
    // String
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    try { msg.getString("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(3,msg.getBytes("prop").length);
   
    // Bytes
    msg = new MapMessageImpl();
    msg.setBytes("prop",dummy);
    msg.markAsReadOnly();
    byte[] data = msg.getBytes("prop");
    assertEquals(3,data.length);
    assertEquals(1, data[0]);
    assertEquals(2, data[1]);
    assertEquals(3, data[2]);
  }
View Full Code Here

TOP

Related Classes of net.timewalker.ffmq3.common.message.MapMessageImpl

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.