Java Code Examples for org.apache.activemq.artemis.api.core.client.ClientSessionFactory#getServerLocator()
The following examples show how to use
org.apache.activemq.artemis.api.core.client.ClientSessionFactory#getServerLocator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupingFailoverTestBase.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void waitForBackupTopologyAnnouncement(ClientSessionFactory sf) throws Exception { long start = System.currentTimeMillis(); ServerLocator locator = sf.getServerLocator(); do { Collection<TopologyMemberImpl> members = locator.getTopology().getMembers(); for (TopologyMemberImpl member : members) { if (member.getBackup() != null) { return; } } Thread.sleep(10); } while (System.currentTimeMillis() - start < ActiveMQTestBase.WAIT_TIMEOUT); throw new IllegalStateException("Timed out waiting for backup announce"); }
Example 2
Source File: ClientConsumerImpl.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * This method deals with messages arrived as regular message but its contents are compressed. * Such messages come from message senders who are configured to compress large messages, and * if some of the messages are compressed below the min-large-message-size limit, they are sent * as regular messages. * <br> * However when decompressing the message, we are not sure how large the message could be.. * for that reason we fake a large message controller that will deal with the message as it was a large message * <br> * Say that you sent a 1G message full of spaces. That could be just bellow 100K compressed but you wouldn't have * enough memory to decompress it */ private void handleCompressedMessage(final ClientMessageInternal clMessage) throws Exception { ClientLargeMessageImpl largeMessage = new ClientLargeMessageImpl(); largeMessage.retrieveExistingData(clMessage); File largeMessageCache = null; if (session.isCacheLargeMessageClient()) { largeMessageCache = File.createTempFile("tmp-large-message-" + largeMessage.getMessageID() + "-", ".tmp"); largeMessageCache.deleteOnExit(); } ClientSessionFactory sf = session.getSessionFactory(); ServerLocator locator = sf.getServerLocator(); long callTimeout = locator.getCallTimeout(); currentLargeMessageController = new LargeMessageControllerImpl(this, largeMessage.getLargeMessageSize(), callTimeout, largeMessageCache); currentLargeMessageController.setLocal(true); //sets the packet ActiveMQBuffer qbuff = clMessage.toCore().getBodyBuffer(); final int bytesToRead = qbuff.writerIndex() - qbuff.readerIndex(); final byte[] body = new byte[bytesToRead]; qbuff.readBytes(body); largeMessage.setLargeMessageController(new CompressedLargeMessageControllerImpl(currentLargeMessageController)); currentLargeMessageController.addPacket(body, body.length, false); handleRegularMessage(largeMessage); }
Example 3
Source File: ClientConsumerImpl.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public synchronized void handleLargeMessage(final ClientLargeMessageInternal clientLargeMessage, long largeMessageSize) throws Exception { if (closing) { // This is ok - we just ignore the message return; } // Flow control for the first packet, we will have others File largeMessageCache = null; if (session.isCacheLargeMessageClient()) { largeMessageCache = File.createTempFile("tmp-large-message-" + clientLargeMessage.getMessageID() + "-", ".tmp"); largeMessageCache.deleteOnExit(); } ClientSessionFactory sf = session.getSessionFactory(); ServerLocator locator = sf.getServerLocator(); long callTimeout = locator.getCallTimeout(); currentLargeMessageController = new LargeMessageControllerImpl(this, largeMessageSize, callTimeout, largeMessageCache); if (clientLargeMessage.isCompressed()) { clientLargeMessage.setLargeMessageController(new CompressedLargeMessageControllerImpl(currentLargeMessageController)); } else { clientLargeMessage.setLargeMessageController(currentLargeMessageController); } handleRegularMessage(clientLargeMessage); }