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

nstream.adapter.common.ext.JmsIngressSettings Maven / Gradle / Ivy

There is a newer version: 4.15.23
Show newest version
// Copyright 2015-2024 Nstream, inc.
//
// Licensed under the Redis Source Available License 2.0 (RSALv2) Agreement;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://redis.com/legal/rsalv2-agreement/
//
// 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 nstream.adapter.common.ext;

import java.util.Properties;
import nstream.adapter.common.AdapterSettings;
import swim.codec.Format;
import swim.codec.Output;
import swim.structure.Form;
import swim.structure.Kind;
import swim.structure.Record;
import swim.structure.Tag;
import swim.structure.Value;
import swim.util.Log;

/**
 * Provides a concrete class to parse and store agent configuration
 * used for JMS ingress by {@code nstream.adapter.jms.JmsIngestingAgent} and
 * {@code JmsIngestingPatch}.
 */
@Tag("jmsIngressSettings")
public class JmsIngressSettings implements AdapterSettings {

  private static final JmsIngressJetTranslator JET_TRANSLATOR = new JmsIngressJetTranslator();

  private final String connectionProvisionName;
  private final String destination;
  private final String jndiProvisionName;
  private final String jndiDestination;
  private final String contentTypeOverride;
  private final String avroSchema;
  private final Value valueMolder;
  private final Value relaySchema;

  public JmsIngressSettings(final String connectionProvisionName,
                            final String destination,
                            final String jndiProvisionName,
                            final String jndiDestination,
                            final String contentTypeOverride,
                            final String avroSchema,
                            final Value valueMolder,
                            final Value relaySchema) {
    this.connectionProvisionName = connectionProvisionName;
    this.destination = destination;
    this.jndiProvisionName = jndiProvisionName;
    this.jndiDestination = jndiDestination;
    this.contentTypeOverride = contentTypeOverride;
    this.avroSchema = avroSchema;
    this.valueMolder = valueMolder;
    this.relaySchema = relaySchema;
  }

  public JmsIngressSettings() {
    this("jmsConnectionProvision", null, null, null, null, null, null, null);
  }

  /**
   * Name of JMS connection provision to be used for ingestion.
   *
   * @return the connection provision name
   */
  public String connectionProvisionName() {
    return this.connectionProvisionName;
  }

  /**
   * JMS destination URL.
   * This is the name of the topic/queue prepended with either 'topic://'
   * or 'queue://'.
   *
   * @return the JMS destination URL
   */
  public String destination() {
    return this.destination;
  }

  /**
   * JNDI provision name.
   *
   * @return the JNDI provision name
   */
  public String jndiProvisionName() {
    return this.jndiProvisionName;
  }

  /**
   * JNDI destination name.
   *
   * @return the JNDI destination name
   */
  public String jndiDestination() {
    return this.jndiDestination;
  }

  /**
   * Content type of the ingested messages.
   * Currently accepted values:
   * 
    *
  • json
  • *
  • xml
  • *
  • recon
  • *
  • plaintext (Default)
  • *
* * @return the content type */ public String contentTypeOverride() { return this.contentTypeOverride; } /** * Avro schema of received messages. * * @return avro schema */ public String avroSchema() { return this.avroSchema; } public Value valueMolder() { return this.valueMolder; } /** * Relay schema definition. * * @return the relay schema */ public Value relaySchema() { return this.relaySchema; } @Override public Output debug(Output output) { output = output.write("JmsIngressSettings").write('.').write("of").write('(').write(')') .write('.').write("connectionProvisionName").write('(').debug(this.connectionProvisionName).write(')') .write('.').write("destination").write('(').debug(this.destination).write(')') .write('.').write("jndiProvisionName").write('(').debug(this.jndiProvisionName).write(')') .write('.').write("jndiDestination").write('(').debug(this.jndiDestination).write(')') .write('.').write("contentTypeOverride").write('(').debug(this.contentTypeOverride).write(')') .write('.').write("avroSchema").write('(').debug(this.avroSchema).write(')') .write('.').write("valueMolder").write('(').debug(this.valueMolder).write(')') .write('.').write("relaySchema").write('(').debug(this.relaySchema).write(')'); return output; } @Override public String toString() { return Format.debug(this); } @Kind private static Form form; private static final JmsIngressSettings DEFAULT = new JmsIngressSettings(); public static Form form() { if (JmsIngressSettings.form == null) { JmsIngressSettings.form = Form.forClass(JmsIngressSettings.class); } return JmsIngressSettings.form; } public static JmsIngressSettings defaultSettings() { return JmsIngressSettings.DEFAULT; } public static Record moldFromProperties(Log log, Properties p) { return JET_TRANSLATOR.moldFromProperties(log, p); } public static JmsIngressSettings translateJet(Log log, JmsIngressSettings base) { return JET_TRANSLATOR.translate(log, base, null); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy