• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessageNotWriteableException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.jms.MessageNotWriteableException的典型用法代码示例。如果您正苦于以下问题:Java MessageNotWriteableException类的具体用法?Java MessageNotWriteableException怎么用?Java MessageNotWriteableException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageNotWriteableException类属于javax.jms包,在下文中一共展示了MessageNotWriteableException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setBytes

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Override
public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException {
   checkName(name);
   if (bodyReadOnly) {
      throw new MessageNotWriteableException("Message is ReadOnly !");
   }

   if (offset + length > value.length) {
      throw new JMSException("Array is too small");
   }
   byte[] temp = new byte[length];
   System.arraycopy(value, offset, temp, 0, length);

   content.put(name, temp);

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:SimpleJMSMapMessage.java


示例2: setObject

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Override
public void setObject(Serializable object) throws JMSException
   {
   	if (bodyIsReadOnly)
   		throw new MessageNotWriteableException("Message body is read-only");
   	
   	assertDeserializationLevel(MessageSerializationLevel.FULL);
   	
       if (object == null)
       {
           body = null;
           return;
       }
       
       try
       {
       	body = SerializationTools.toByteArray(object);
       }
       catch (Exception e)
       {
       	throw new FFMQException("Cannot serialize object message body","MESSAGE_ERROR",e);
       }
   }
 
开发者ID:timewalker74,项目名称:ffmq,代码行数:24,代码来源:ObjectMessageImpl.java


示例3: testResetMakesReadble

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testResetMakesReadble() throws Exception
{
    try
    {
        JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
        bm.writeInt(10);
        bm.reset();
        bm.writeInt(12);
        fail("expected exception did not occur");
    }
    catch (MessageNotWriteableException m)
    {
        // ok
    }
    catch (Exception e)
    {
        fail("expected MessageNotWriteableException, got " + e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:20,代码来源:BytesMessageTest.java


示例4: testResetMakesReadble

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testResetMakesReadble() throws Exception
{
    try
    {
        JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
        bm.writeInt(10);
        bm.reset();
        bm.writeInt(12);
        fail("expected exception did not occur");
    }
    catch (MessageNotWriteableException m)
    {
        // ok
    }
    catch (Exception e)
    {
        fail("expected MessageNotWriteableException, got " + e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:20,代码来源:StreamMessageTest.java


示例5: testClearBody

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Test
public void testClearBody() throws JMSException, IOException {
    JmsTextMessage textMessage = factory.createTextMessage();
    textMessage.setText("string");
    textMessage.clearBody();
    assertFalse(textMessage.isReadOnlyBody());
    assertNull(textMessage.getText());
    try {
        textMessage.setText("String");
        textMessage.getText();
    } catch (MessageNotWriteableException mnwe) {
        fail("should be writeable");
    } catch (MessageNotReadableException mnre) {
        fail("should be readable");
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsTextMessageTest.java


示例6: testReadOnlyBody

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Test
public void testReadOnlyBody() throws JMSException {
    JmsTextMessage textMessage = factory.createTextMessage();
    textMessage.setText("test");
    textMessage.setReadOnlyBody(true);
    try {
        textMessage.getText();
    } catch (MessageNotReadableException e) {
        fail("should be readable");
    }
    try {
        textMessage.setText("test");
        fail("should throw exception");
    } catch (MessageNotWriteableException mnwe) {
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsTextMessageTest.java


示例7: testReceivedMessageIsReadOnlyAndThrowsMNWE

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
/**
 * Test that we are not able to write to a received message without calling
 * {@link JmsMapMessage#clearBody()}
 *
 * @throws Exception if an error occurs during the test.
 */
@Test
public void testReceivedMessageIsReadOnlyAndThrowsMNWE() throws Exception {
    JmsMapMessageFacade facade = new JmsTestMapMessageFacade();
    String myKey1 = "key1";
    facade.put(myKey1, "value1");
    JmsMapMessage mapMessage = new JmsMapMessage(facade);
    mapMessage.onDispatch();

    try {
        mapMessage.setObject("name", "value");
        fail("expected exception to be thrown");
    } catch (MessageNotWriteableException mnwe) {
        // expected
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:22,代码来源:JmsMapMessageTest.java


示例8: testClearPropertiesClearsReadOnly

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Test
public void testClearPropertiesClearsReadOnly() throws Exception {
    JmsMessage msg = factory.createMessage();
    msg.onDispatch();

    try {
        msg.setObjectProperty("test", "value");
        fail("should throw exception");
    } catch (MessageNotWriteableException e) {
        // Expected
    }

    assertTrue(msg.isReadOnlyProperties());

    msg.clearProperties();

    msg.setObjectProperty("test", "value");

    assertFalse(msg.isReadOnlyProperties());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:21,代码来源:JmsMessageTest.java


示例9: testReceivedObjectMessageThrowsMessageNotWriteableExceptionOnSetObject

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
/**
 * Test that attempting to write bytes to a received message (without calling {@link ObjectMessage#clearBody()} first)
 * causes a {@link MessageNotWriteableException} to be thrown due to being read-only.
 *
 * @throws Exception if an error occurs during the test.
 */
@Test
public void testReceivedObjectMessageThrowsMessageNotWriteableExceptionOnSetObject() throws Exception {
    String content = "myStringContent";
    JmsObjectMessageFacade facade = new JmsTestObjectMessageFacade();
    facade.setObject(content);
    JmsObjectMessage objectMessage = new JmsObjectMessage(facade);
    objectMessage.onDispatch();

    try {
        objectMessage.setObject("newObject");
        fail("Expected exception to be thrown");
    } catch (MessageNotWriteableException mnwe) {
        // expected
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:22,代码来源:JmsObjectMessageTest.java


示例10: convertToRuntimeException

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
    if (e instanceof javax.jms.IllegalStateException) {
        return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidClientIDException) {
        return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidDestinationException) {
        return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidSelectorException) {
        return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof JMSSecurityException) {
        return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageFormatException) {
        return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageNotWriteableException) {
        return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof ResourceAllocationException) {
        return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionInProgressException) {
        return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionRolledBackException) {
        return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:34,代码来源:Utils.java


示例11: convertMessageNotWritableException

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Test
public void convertMessageNotWritableException() throws JMSException {
	Message<String> message = createTextMessage();
	MessageConverter messageConverter = mock(MessageConverter.class);
	willThrow(MessageNotWriteableException.class).given(messageConverter).toMessage(eq(message), anyObject());
	messagingTemplate.setJmsMessageConverter(messageConverter);
	invokeMessageCreator("myQueue");

	thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
	messagingTemplate.send("myQueue", message);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JmsMessagingTemplateTests.java


示例12: initializeWriting

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
private void initializeWriting() throws MessageNotWriteableException {
    checkReadOnlyBody();
    if (this.dataOut == null) {
        this.bytesOut = new ByteArrayOutputStream();
        OutputStream os = bytesOut;
        ActiveMQConnection connection = getConnection();
        if (connection != null && connection.isUseCompression()) {
            compressed = true;
            os = new DeflaterOutputStream(os);
        }
        this.dataOut = new DataOutputStream(os);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:14,代码来源:ActiveMQStreamMessage.java


示例13: createMessage

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
   ActiveMQTextMessage message = new ActiveMQTextMessage();
   message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
   message.setDestination(destination);
   message.setPersistent(false);
   try {
      message.setText("Test Message Payload.");
   } catch (MessageNotWriteableException e) {
   }
   return message;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:BrokerNetworkWithStuckMessagesTest.java


示例14: assertSendTextMessage

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
protected void assertSendTextMessage(ActiveMQDestination destination,
                                     String text) throws MessageNotWriteableException {
   large = true;

   ActiveMQTextMessage expected = new ActiveMQTextMessage();

   expected.setText(text);
   expected.setDestination(destination);

   try {
      LOG.info("About to send message of type: " + expected.getClass());
      producer.oneway(expected);

      // lets send a dummy command to ensure things don't block if we
      // discard the last one
      // keepalive does not have a commandId...
      // producer.oneway(new KeepAliveInfo());
      producer.oneway(new ProducerInfo());
      producer.oneway(new ProducerInfo());

      Command received = assertCommandReceived();
      assertTrue("Should have received an ActiveMQTextMessage but was: " + received, received instanceof ActiveMQTextMessage);
      ActiveMQTextMessage actual = (ActiveMQTextMessage) received;

      assertEquals("getDestination", expected.getDestination(), actual.getDestination());
      assertEquals("getText", expected.getText(), actual.getText());

      LOG.info("Received text message with: " + actual.getText().length() + " character(s)");
   } catch (Exception e) {
      LOG.info("Caught: " + e);
      e.printStackTrace();
      fail("Failed to send to transport: " + e);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:UdpTestSupport.java


示例15: testClearBody

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testClearBody() throws JMSException, IOException {
   ActiveMQTextMessage textMessage = new ActiveMQTextMessage();
   textMessage.setText("string");
   textMessage.clearBody();
   assertFalse(textMessage.isReadOnlyBody());
   assertNull(textMessage.getText());
   try {
      textMessage.setText("String");
      textMessage.getText();
   } catch (MessageNotWriteableException mnwe) {
      fail("should be writeable");
   } catch (MessageNotReadableException mnre) {
      fail("should be readable");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQTextMessageTest.java


示例16: testReadOnlyBody

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testReadOnlyBody() throws JMSException {
   ActiveMQTextMessage textMessage = new ActiveMQTextMessage();
   textMessage.setText("test");
   textMessage.setReadOnlyBody(true);
   try {
      textMessage.getText();
   } catch (MessageNotReadableException e) {
      fail("should be readable");
   }
   try {
      textMessage.setText("test");
      fail("should throw exception");
   } catch (MessageNotWriteableException mnwe) {
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQTextMessageTest.java


示例17: testClearBody

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testClearBody() throws JMSException {
   ActiveMQObjectMessage objectMessage = new ActiveMQObjectMessage();
   try {
      objectMessage.setObject("String");
      objectMessage.clearBody();
      assertFalse(objectMessage.isReadOnlyBody());
      assertNull(objectMessage.getObject());
      objectMessage.setObject("String");
      objectMessage.getObject();
   } catch (MessageNotWriteableException mnwe) {
      fail("should be writeable");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:14,代码来源:ActiveMQObjectMessageTest.java


示例18: testSetReadOnly

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
public void testSetReadOnly() {
   ActiveMQMessage msg = new ActiveMQMessage();
   msg.setReadOnlyProperties(true);
   boolean test = false;
   try {
      msg.setIntProperty("test", 1);
   } catch (MessageNotWriteableException me) {
      test = true;
   } catch (JMSException e) {
      e.printStackTrace(System.err);
      test = false;
   }
   assertTrue(test);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:ActiveMQMessageTest.java


示例19: writeBoolean

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Override
public void writeBoolean(final boolean value) throws JMSException {
   if (!bodyWriteOnly) {
      throw new MessageNotWriteableException("The message body is readonly");
   }
   content.add(new Boolean(value));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:SimpleJMSStreamMessage.java


示例20: writeByte

import javax.jms.MessageNotWriteableException; //导入依赖的package包/类
@Override
public void writeByte(final byte value) throws JMSException {
   if (!bodyWriteOnly) {
      throw new MessageNotWriteableException("The message body is readonly");
   }
   content.add(new Byte(value));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:SimpleJMSStreamMessage.java



注:本文中的javax.jms.MessageNotWriteableException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ThemeResource类代码示例发布时间:2022-05-22
下一篇:
Java RowIndexEntry类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap