Search in sources :

Example 6 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v630.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerIntegrationTest method testBoundWithInvalidAffinityKey.

@Test
public void testBoundWithInvalidAffinityKey() {
    SpannerBlockingStub stub = getSpannerBlockingStub();
    CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
    Session session = stub.createSession(req);
    expectedEx.expect(StatusRuntimeException.class);
    expectedEx.expectMessage("INVALID_ARGUMENT: Invalid GetSession request.");
    // No channel bound with the key "invalid_session", will use the least busy one.
    stub.getSession(GetSessionRequest.newBuilder().setName("invalid_session").build());
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) SpannerBlockingStub(com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub) Session(com.google.spanner.v1.Session) Test(org.junit.Test)

Example 7 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v630.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerIntegrationTest method createAsyncSessions.

private List<String> createAsyncSessions(SpannerStub stub) throws Exception {
    List<AsyncResponseObserver<Session>> resps = new ArrayList<>();
    List<String> respNames = new ArrayList<>();
    // Check the state of the channel first.
    assertEquals(ConnectivityState.IDLE, gcpChannel.getState(false));
    // Check CreateSession with multiple channels and streams,
    CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
    for (int i = 0; i < MAX_CHANNEL * MAX_STREAM; i++) {
        AsyncResponseObserver<Session> resp = new AsyncResponseObserver<Session>();
        stub.createSession(req, resp);
        resps.add(resp);
    }
    checkChannelRefs(MAX_CHANNEL, MAX_STREAM, 0);
    for (AsyncResponseObserver<Session> resp : resps) {
        respNames.add(resp.get().getName());
    }
    // Since createSession will bind the key, check the number of keys bound with channels.
    assertEquals(ConnectivityState.READY, gcpChannel.getState(false));
    assertEquals(MAX_CHANNEL * MAX_STREAM, gcpChannel.affinityKeyToChannelRef.size());
    checkChannelRefs(MAX_CHANNEL, 0, MAX_STREAM);
    return respNames;
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) ArrayList(java.util.ArrayList) Session(com.google.spanner.v1.Session)

Example 8 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v630.CreateSessionRequest in project swiftmq-client by iitsoftware.

the class QueueConnectionImpl method createQueueSession.

public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
    verifyState();
    SessionImpl queueSession = null;
    CreateSessionReply reply = null;
    try {
        reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.QUEUE_SESSION, 0));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (reply.isOk()) {
        int dispatchId = reply.getSessionDispatchId();
        queueSession = new SessionImpl(SessionImpl.TYPE_QUEUE_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, null);
        queueSession.setUserName(getUserName());
        queueSession.setMyDispatchId(addRequestService(queueSession));
        addSession(queueSession);
    } else {
        throw ExceptionConverter.convert(reply.getException());
    }
    return (queueSession);
}
Also used : CreateSessionRequest(com.swiftmq.jms.smqp.v750.CreateSessionRequest) CreateSessionReply(com.swiftmq.jms.smqp.v750.CreateSessionReply) IllegalStateException(javax.jms.IllegalStateException)

Example 9 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v630.CreateSessionRequest in project swiftmq-client by iitsoftware.

the class TopicConnectionImpl method createTopicSession.

public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException {
    verifyState();
    SessionImpl topicSession = null;
    CreateSessionReply reply = null;
    try {
        reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.TOPIC_SESSION, 0));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (reply.isOk()) {
        int dispatchId = reply.getSessionDispatchId();
        String cid = clientID != null ? clientID : internalCID;
        topicSession = new SessionImpl(SessionImpl.TYPE_TOPIC_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, cid);
        topicSession.setUserName(userName);
        topicSession.setMyDispatchId(addRequestService(topicSession));
        addSession(topicSession);
    } else {
        throw ExceptionConverter.convert(reply.getException());
    }
    return (topicSession);
}
Also used : CreateSessionRequest(com.swiftmq.jms.smqp.v750.CreateSessionRequest) CreateSessionReply(com.swiftmq.jms.smqp.v750.CreateSessionReply) JMSException(javax.jms.JMSException)

Example 10 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v630.CreateSessionRequest in project swiftmq-client by iitsoftware.

the class QueueConnectionImpl method createQueueSession.

public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
    verifyState();
    SessionImpl queueSession = null;
    CreateSessionReply reply = null;
    try {
        reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.QUEUE_SESSION, 0));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (reply.isOk()) {
        int dispatchId = reply.getSessionDispatchId();
        queueSession = new SessionImpl(SessionImpl.TYPE_QUEUE_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, null);
        queueSession.setUserName(getUserName());
        queueSession.setMyDispatchId(addRequestService(queueSession));
        addSession(queueSession);
    } else {
        throw ExceptionConverter.convert(reply.getException());
    }
    return (queueSession);
}
Also used : CreateSessionRequest(com.swiftmq.jms.smqp.v610.CreateSessionRequest) CreateSessionReply(com.swiftmq.jms.smqp.v610.CreateSessionReply) IllegalStateException(javax.jms.IllegalStateException)

Aggregations

CreateSessionRequest (com.google.spanner.v1.CreateSessionRequest)11 Session (com.google.spanner.v1.Session)11 JMSException (javax.jms.JMSException)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 SpannerBlockingStub (com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub)4 IllegalStateException (javax.jms.IllegalStateException)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 CreateSessionReply (com.swiftmq.jms.smqp.v600.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v600.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v610.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v610.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v630.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v630.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v750.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v750.CreateSessionRequest)2 HashMap (java.util.HashMap)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ByteString (com.google.protobuf.ByteString)1