本文整理汇总了Java中org.apache.activemq.artemis.api.core.client.ClientSession类的典型用法代码示例。如果您正苦于以下问题:Java ClientSession类的具体用法?Java ClientSession怎么用?Java ClientSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientSession类属于org.apache.activemq.artemis.api.core.client包,在下文中一共展示了ClientSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startSession
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
private static ClientSession startSession(
ClientSessionFactory csf,
FunctionE<ClientSessionFactory, ClientSession> createSession)
throws ActiveMQException {
boolean created = false;
try {
ClientSession session = createSession.apply(csf);
session.start();
created = true;
return session;
} finally {
if (!created) { // (1)
csf.close();
}
}
}
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:ServerConnector.java
示例2: newTask
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
private DequeueTask<ArtemisMessage, String> newTask(String sentData)
throws Exception {
CoreQueueConfiguration q = new CoreQueueConfiguration();
q.setName("q");
ClientSession sesh = mock(ClientSession.class);
ClientConsumer receiver = mock(ClientConsumer.class);
when(sesh.createConsumer(q.getName(), false)).thenReturn(receiver);
QConnector<ArtemisMessage> connector = new ArtemisQConnector(q, sesh);
DequeueTask<ArtemisMessage, String> task =
new DequeueTask<>(connector, this, deserializer(sentData), true);
verify(receiver).setMessageHandler(any());
return task;
}
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:17,代码来源:DequeueTaskTest.java
示例3: initMocks
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
protected void initMocks() throws ActiveMQException {
CoreQueueConfiguration q = new CoreQueueConfiguration();
q.setName("q");
ClientSession sesh = mock(ClientSession.class);
producer = mock(ClientProducer.class);
when(sesh.createProducer(q.getAddress())).thenReturn(producer);
msgToQueue = mock(ClientMessage.class);
boolean durable = true;
when(sesh.createMessage(durable)).thenReturn(msgToQueue);
msgBody = mock(ActiveMQBuffer.class);
when(msgToQueue.getBodyBuffer()).thenReturn(msgBody);
connector = new ArtemisQConnector(q, sesh);
}
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:BaseSendTest.java
示例4: createSessionFactoryAndWaitForTopology
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
protected final ClientSessionFactoryInternal createSessionFactoryAndWaitForTopology(ServerLocator locator,
TransportConfiguration transportConfiguration,
int topologyMembers) throws Exception {
CountDownLatch countDownLatch = new CountDownLatch(topologyMembers * 2);
locator.addClusterTopologyListener(new LatchClusterTopologyListener(countDownLatch));
ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) locator.createSessionFactory(transportConfiguration);
addSessionFactory(sf);
assertTrue("topology members expected " + topologyMembers, countDownLatch.await(5, TimeUnit.SECONDS));
closeSessionFactory(sf);
sf = (ClientSessionFactoryInternal) locator.createSessionFactory(liveServer.getServer().getNodeID().toString());
addSessionFactory(sf);
if (sf2 == null) {
sf2 = (ClientSessionFactoryInternal) locator.createSessionFactory(backupServer.getServer().getNodeID().toString());
ClientSession session2 = createSession(sf2, false, false);
session2.createQueue(ADDRESS, ADDRESS, null, true);
addSessionFactory(sf2);
}
return sf;
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:LiveToLiveFailoverTest.java
示例5: testAutClose
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testAutClose() throws Exception {
ServerLocator locatorx;
ClientSession sessionx;
ClientSessionFactory factoryx;
try (ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, false)) {
locatorx = locator;
sessionx = session;
factoryx = factory;
}
assertTrue(locatorx.isClosed());
assertTrue(sessionx.isClosed());
assertTrue(factoryx.isClosed());
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:AutoCloseCoreTest.java
示例6: deploy
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
public void deploy(QueueDeployment queueDeployment) throws Exception {
if (!started) {
throw new Exception("You must start() this class instance before deploying");
}
String queueName = queueDeployment.getName();
try (ClientSession session = sessionFactory.createSession(false, false, false)) {
ClientSession.AddressQuery query = session.addressQuery(SimpleString.toSimpleString(queueName));
if (!query.isExists()) {
session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, true);
session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend());
} else {
ClientSession.QueueQuery qquery = session.queueQuery(SimpleString.toSimpleString(queueName));
if (!qquery.isExists()) {
session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend());
}
}
}
destination.createQueueResource(queueName, queueDeployment.isDurableSend(), queueDeployment.getConsumerSessionTimeoutSeconds(), queueDeployment.isDuplicatesAllowed());
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:QueueServiceManager.java
示例7: setupServer
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
private void setupServer(final JournalType journalType) throws Exception {
Configuration config = createDefaultNettyConfig().setJournalType(journalType).setJournalFileSize(ActiveMQDefaultConfiguration.getDefaultJournalFileSize()).setJournalMinFiles(ActiveMQDefaultConfiguration.getDefaultJournalMinFiles()).setJournalCompactMinFiles(2).setJournalCompactPercentage(50);
server = createServer(true, config);
server.start();
ServerLocator locator = createNettyNonHALocator().setBlockOnDurableSend(false).setBlockOnNonDurableSend(false).setBlockOnAcknowledge(false);
sf = createSessionFactory(locator);
ClientSession sess = sf.createSession();
try {
sess.createQueue(ADDRESS, QUEUE, true);
} catch (Exception ignored) {
}
sess.close();
locator.close();
locator = createInVMNonHALocator();
sf = createSessionFactory(locator);
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:MultiThreadConsumerStressTest.java
示例8: testClosingTemporaryTopicDeletesQueue
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testClosingTemporaryTopicDeletesQueue() throws JMSException, ActiveMQException {
conn = cf.createConnection();
Assert.assertEquals(1, server.getRemotingService().getConnections().size());
session1 = (ActiveMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQTemporaryTopic topic = (ActiveMQTemporaryTopic) session1.createTemporaryTopic();
String address = topic.getAddress();
session1.close();
conn.close();
conn2 = cf.createConnection();
session2 = (ActiveMQSession) conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
ClientSession cs = session2.getCoreSession();
try {
cs.createConsumer(address);
fail("the address from the TemporaryTopic still exists!");
} catch (ActiveMQException e) {
assertEquals("expecting 'queue does not exist'", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, e.getType());
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:CloseDestroyedConnectionTest.java
示例9: testSendMultipleSuspendErrorCheck
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testSendMultipleSuspendErrorCheck() throws Exception {
ClientSession session = null;
session = sessionFactory.createSession(true, false, false);
Xid xid = newXID();
session.start(xid, XAResource.TMNOFLAGS);
try {
session.start(xid, XAResource.TMRESUME);
Assert.fail("XAException expected");
} catch (XAException e) {
Assert.assertEquals(XAException.XAER_PROTO, e.errorCode);
}
session.close();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:BasicXaTest.java
示例10: testOneWaySSL
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testOneWaySSL() throws Exception {
createCustomSslServer();
String text = RandomUtil.randomString();
tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
tc.getParams().put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, storeType);
tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, CLIENT_SIDE_TRUSTSTORE);
tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, PASSWORD);
ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
ClientSession session = addClientSession(sf.createSession(false, true, true));
session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false);
ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
ClientMessage message = createTextMessage(session, text);
producer.send(message);
ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
session.start();
ClientMessage m = consumer.receive(1000);
Assert.assertNotNull(m);
Assert.assertEquals(text, m.getBodyBuffer().readString());
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:CoreClientOverOneWaySSLTest.java
示例11: testClearListener
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testClearListener() throws Exception {
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.start();
ClientConsumer consumer = session.createConsumer(QUEUE);
consumer.setMessageHandler(new MessageHandler() {
@Override
public void onMessage(final ClientMessage msg) {
}
});
consumer.setMessageHandler(null);
consumer.receiveImmediate();
session.close();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:ConsumerTest.java
示例12: testSimpleSendNoXAJMSContext
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testSimpleSendNoXAJMSContext() throws Exception {
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
try (ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession();
ClientConsumer consVerify = session.createConsumer(MDBQUEUE);
JMSContext jmsctx = qraConnectionFactory.createContext();
) {
session.start();
// These next 4 lines could be written in a single line however it makes difficult for debugging
JMSProducer producer = jmsctx.createProducer();
producer.setProperty("strvalue", "hello");
TextMessage msgsend = jmsctx.createTextMessage("hello");
producer.send(q, msgsend);
ClientMessage msg = consVerify.receive(1000);
assertNotNull(msg);
assertEquals("hello", msg.getStringProperty("strvalue"));
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:OutgoingConnectionJTATest.java
示例13: testSimpleSendNoXAJMS1
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testSimpleSendNoXAJMS1() throws Exception {
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
try (ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession();
ClientConsumer consVerify = session.createConsumer(MDBQUEUE);
Connection conn = qraConnectionFactory.createConnection();
) {
Session jmsSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
session.start();
MessageProducer producer = jmsSess.createProducer(q);
// These next 4 lines could be written in a single line however it makes difficult for debugging
TextMessage msgsend = jmsSess.createTextMessage("hello");
msgsend.setStringProperty("strvalue", "hello");
producer.send(msgsend);
ClientMessage msg = consVerify.receive(1000);
assertNotNull(msg);
assertEquals("hello", msg.getStringProperty("strvalue"));
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:OutgoingConnectionJTATest.java
示例14: testRouteToSingleTemporaryQueue
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testRouteToSingleTemporaryQueue() throws Exception {
ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createTemporaryQueue(addressA, queueA);
int numMessages = 300;
ClientProducer p = sendSession.createProducer(addressA);
for (int i = 0; i < numMessages; i++) {
p.send(sendSession.createMessage(false));
}
ClientSession session = cf.createSession(false, true, true);
ClientConsumer c1 = session.createConsumer(queueA);
session.start();
for (int i = 0; i < numMessages; i++) {
ClientMessage m = c1.receive(5000);
Assert.assertNotNull(m);
m.acknowledge();
}
Assert.assertNull(c1.receiveImmediate());
sendSession.close();
session.close();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:RoutingTest.java
示例15: checkUserReceiveNoSend
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
private void checkUserReceiveNoSend(final String queue,
final ClientSession connection,
final ClientSession sendingConn) throws Exception {
connection.start();
try {
ClientProducer prod = connection.createProducer(queue);
ClientMessage m = connection.createMessage(false);
try {
prod.send(m);
Assert.fail("should throw exception");
} catch (ActiveMQException e) {
// pass
}
prod = sendingConn.createProducer(queue);
prod.send(m);
ClientConsumer con = connection.createConsumer(queue);
ClientMessage rec = con.receive(1000);
Assert.assertNotNull(rec);
rec.acknowledge();
} finally {
connection.stop();
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:SecurityTest.java
示例16: testCreateSessionWithNullUserPass
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testCreateSessionWithNullUserPass() throws Exception {
ActiveMQServer server = createServer();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("guest", "guest");
securityManager.getConfiguration().setDefaultUser("guest");
server.start();
ClientSessionFactory cf = createSessionFactory(locator);
try {
ClientSession session = cf.createSession(false, true, true);
session.close();
} catch (ActiveMQException e) {
Assert.fail("should not throw exception");
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:SecurityTest.java
示例17: invokeOperation
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
public Object invokeOperation(final Class desiredType,
final String operationName,
final Object... args) throws Exception {
try (ClientSessionFactory sessionFactory = locator.createSessionFactory();
ClientSession session = getSession(sessionFactory);
ClientRequestor requestor = getClientRequestor(session)) {
ClientMessage m = session.createMessage(false);
ManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
ClientMessage reply = requestor.request(m);
if (reply != null) {
if (ManagementHelper.hasOperationSucceeded(reply)) {
return ManagementHelper.getResult(reply, desiredType);
} else {
throw new Exception((String) ManagementHelper.getResult(reply));
}
} else {
return null;
}
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:CoreMessagingProxy.java
示例18: testCreateTempQueueWithRole
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testCreateTempQueueWithRole() throws Exception {
ActiveMQServer server = createServer();
server.start();
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("auser", "pass");
Role role = new Role("arole", false, false, false, false, true, false, false, false, false, false);
Set<Role> roles = new HashSet<>();
roles.add(role);
securityRepository.addMatch(SecurityTest.addressA, roles);
securityManager.getConfiguration().addRole("auser", "arole");
ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
session.close();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:SecurityTest.java
示例19: testCreateTempQueueWithoutRole
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
@Test
public void testCreateTempQueueWithoutRole() throws Exception {
ActiveMQServer server = createServer();
server.start();
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("auser", "pass");
Role role = new Role("arole", false, false, false, false, false, false, false, false, false, false);
Set<Role> roles = new HashSet<>();
roles.add(role);
securityRepository.addMatch(SecurityTest.addressA, roles);
securityManager.getConfiguration().addRole("auser", "arole");
ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
try {
session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
Assert.fail("should throw exception");
} catch (ActiveMQSecurityException se) {
//ok
} catch (ActiveMQException e) {
fail("Invalid Exception type:" + e.getType());
}
session.close();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityTest.java
示例20: ServerConnector
import org.apache.activemq.artemis.api.core.client.ClientSession; //导入依赖的package包/类
/**
* Connects to the Artemis server and starts a client session.
* @param locator locates the Artemis server.
* @param createSession factory method to create a new session.
* @throws Exception if the connection could not be established or the
* session could not be started.
* @throws NullPointerException if any argument is {@code null}.
*/
public ServerConnector(
ServerLocator locator,
FunctionE<ClientSessionFactory, ClientSession> createSession)
throws Exception {
requireNonNull(locator, "locator");
requireNonNull(createSession, "createSession");
this.factory = locator.createSessionFactory();
this.session = startSession(factory, createSession);
}
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:19,代码来源:ServerConnector.java
注:本文中的org.apache.activemq.artemis.api.core.client.ClientSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论