All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gatling.javaapi.jms.JmsProtocolBuilder Maven / Gradle / Ivy

There is a newer version: 3.13.1
Show newest version
/*
 * Copyright 2011-2024 GatlingCorp (https://gatling.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.gatling.javaapi.jms;

import static io.gatling.javaapi.core.internal.Converters.toScalaDuration;

import edu.umd.cs.findbugs.annotations.NonNull;
import io.gatling.core.protocol.Protocol;
import io.gatling.javaapi.core.ProtocolBuilder;
import io.gatling.javaapi.jms.internal.JmsMessageMatchers;
import java.time.Duration;
import javax.jms.ConnectionFactory;

/**
 * DSL for building JMS Protocol
 * configurations
 *
 * 

Immutable, so all methods return a new occurrence and leave the original unmodified. */ public final class JmsProtocolBuilder implements ProtocolBuilder { public static final class Base { public static final Base INSTANCE = new Base(); private Base() {} /** * Define a programmatic ConnectionFactory * * @param cf the ConnectionFactory * @return a new DSL instance */ @NonNull public JmsProtocolBuilder connectionFactory(@NonNull ConnectionFactory cf) { return new JmsProtocolBuilder( io.gatling.jms.protocol.JmsProtocolBuilderBase.connectionFactory(cf)); } /** * Define a JNDI ConnectionFactory * * @param cfb the ConnectionFactory * @return a new DSL instance */ @NonNull public JmsProtocolBuilder connectionFactory(@NonNull JmsJndiConnectionFactoryBuilder cfb) { return new JmsProtocolBuilder( io.gatling.jms.protocol.JmsProtocolBuilderBase.connectionFactory(cfb.build())); } } private final io.gatling.jms.protocol.JmsProtocolBuilder wrapped; public JmsProtocolBuilder(io.gatling.jms.protocol.JmsProtocolBuilder wrapped) { this.wrapped = wrapped; } @Override public Protocol protocol() { return wrapped.build(); } /** * Define the connection credentials * * @param user the user * @param password the password * @return a new instance */ @NonNull public JmsProtocolBuilder credentials(@NonNull String user, @NonNull String password) { return new JmsProtocolBuilder(wrapped.credentials(user, password)); } /** * Use the persistent delivery mode * * @return a new instance */ @NonNull public JmsProtocolBuilder usePersistentDeliveryMode() { return new JmsProtocolBuilder(wrapped.usePersistentDeliveryMode()); } /** * Use the non-persistent delivery mode * * @return a new instance */ @NonNull public JmsProtocolBuilder useNonPersistentDeliveryMode() { return new JmsProtocolBuilder(wrapped.useNonPersistentDeliveryMode()); } /** * Match outbound and inbound messages based on messageId * * @return a new instance */ @NonNull public JmsProtocolBuilder matchByMessageId() { return new JmsProtocolBuilder(wrapped.matchByMessageId()); } /** * Match outbound and inbound messages based on correlationId * * @return a new instance */ @NonNull public JmsProtocolBuilder matchByCorrelationId() { return new JmsProtocolBuilder(wrapped.matchByCorrelationId()); } /** * Provide a custom message matcher * * @param matcher the custom message matcher * @return a new instance */ @NonNull public JmsProtocolBuilder messageMatcher(@NonNull JmsMessageMatcher matcher) { return new JmsProtocolBuilder(wrapped.messageMatcher(JmsMessageMatchers.toScala(matcher))); } /** * Define a reply timeout * * @param timeout the timeout in seconds * @return a new instance */ @NonNull public JmsProtocolBuilder replyTimeout(long timeout) { return replyTimeout(Duration.ofSeconds(timeout)); } /** * Define a reply timeout * * @param timeout the timeout * @return a new instance */ @NonNull public JmsProtocolBuilder replyTimeout(Duration timeout) { return new JmsProtocolBuilder(wrapped.replyTimeout(toScalaDuration(timeout))); } /** * Define the number of listener threads * * @param threadCount the number of threads * @return a new instance */ @NonNull public JmsProtocolBuilder listenerThreadCount(int threadCount) { return new JmsProtocolBuilder(wrapped.listenerThreadCount(threadCount)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy