【消息中间件Solace】Solace Messaging and Solace API

参考:

https://solace.com/samples/solace-samples-java/publish-subscribe/

https://docs.solace.com/Solace-JMS-API/Establishing-Connections.htm

https://docs.solace.com/API-Developer-Online-Ref-Documentation/jms/index.html

基本概念:

https://www.cnblogs.com/cathygx/p/12869638.html

https://www.cnblogs.com/cathygx/p/12869643.html

Solace Connectivity Properties

ResourceValueDescription
Host String This is the address clients use when connecting to the Solace messaging to send and receive messages. (Format: DNS_NAME:Port or IP:Port)
Message VPN String The Solace message router Message VPN that this client should connect to.
Client Username String The client username. (See Notes below)
Client Password String The client password. (See Notes below)

 

 

 

 

 

Get access to a Solace appliance

  • Contact your Solace appliance administrators and obtain the following:
    • A Solace Message-VPN where you can produce and consume direct and persistent messages
    • The host name or IP address of the Solace appliance hosting your Message-VPN
    • A username and password to access the Solace appliance

Get the API: Using Gradle

compile("com.solacesystems:sol-jcsmp:10.2.0")

Get the API: Using Maven

<dependency>
  <groupId>com.solacesystems</groupId>
  <artifactId>sol-jcsmp</artifactId>
  <version>[10,)</version>
</dependency>

 

Example:

 

Connection Factories

https://docs.solace.com/Solace-JMS-API/Connection-Factories.htm

Before creating a connection with a Connection Factory object, the Connection Factory properties should be modified, as required, because the data channel is established according to the Connection Factory’s configuration parameters. Any Connection Factory property that is not explicitly set will use the default values.

Once a SolConnectionFactory object has been successfully created or looked up (refer to Obtaining Connection Factories), and the Connection Factory properties are modified, as necessary, a client can use it to create a JMS connection (refer to Creating JMS Connections).

JMS Properties Reference

https://docs.solace.com/Solace-JMS-API/JMS-Properties-Reference.htm

This section lists all of the JMS properties that can be set. The JMS properties are listed in the following functional groups:

For each group, all of the available sources from which a property can be specified are provided in order of priority.

Important Connection Properties

URL

Authentication Scheme

Message VPN

Secure Connections

To use secure JNDI and JMS connections, you must configure the following TLS/SSL‑specific connection properties:

  • SSL Cipher Suite
  • SSL Certificate Date Validation
  • SSL Certificate Validation
  • SSL Protocol
  • SSL Trust Store
  • SSL Trust Store Format
  • SSL Trust Store Password
  • SSL Trusted Common Name List

    For details on these properties, refer to JNDI Connection Properties and Data Connection Properties.

In addition, the event broker that you want to create a secure connection to must be properly configured for TLS/ SSL service, and the appropriate server certificate must be in place. For information on configuring an event broker to allow for secure connections, refer to TLS/SSL Service.

Related Samples

For an example of how to use client certificate authentication, refer to the SolJMSSecureSession.java sample.

Authorizing Clients

After a connecting client is authenticated with an event broker, access to event broker resources and messaging capabilities must be authorized for the client.

For a client to be authorized, it must provide the host event broker with a client username that matches one that is provisioned on the Message VPN to which the connection has been made. If there is a match, the client’s connection is authorized, and the Access Control List (ACL) profile and client profile that are assigned to the provisioned client username are then used to provide the client with its access permissions and messaging capabilities.

ACLs define whether the client is permitted to connect to the Message VPN, and, if it is, permissions are assigned to the client that set whether it can publish messages to topics, whether it can subscribe to topics, and whether those publish and subscribe rights are limited to a specific topics.

Client profiles contain a set of common configuration parameters that can be applied to groups of clients, which allows consistent configurations to be readily defined for many clients. Some of the configurations covered by client profiles includes the maximum number of subscriptions client may use and whether clients may use message eliding, publish and/or receive messages using Guaranteed transport, create endpoints, and so on.

Programmatically Creating Connection Factories

 

 

Looking Up Connection Factories from Solace JNDI Stores

 

Looking Up Connection Factories from External JNDI Stores

Looking Up a Connection Factory From an External JNDI Store

 

 

Creating JMS Connections

createConnection()—creates a JMS connection with the client authentication credentials provided through the System, Initial Context, JNDI, URL, and/or Connection Factory property sources.

createConnection(String username, String password)—When using basic client authentication (the default), this method creates a JMS connection using an explicit username and password. The provided username and password overwrite any value that was implicitly set through other JMS property sources.

 

Starting JMS Connections

To begin receiving messages over a JMS connection, the client application must call the start() method after the connection is established.

Stopping or Closing JMS Connections

To stop or close a JMS connection, call one of the following methods:

  • Connection.stop()—Temporarily stops the delivery of incoming messages over the connection. When a connection is stopped, the delivery of messages to the connection’s consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners. To restart the delivery of messages, call Connection.start().

    When using Guaranteed Transport, published Non-Persistent and Persistent messages are spooled for consumers when the connection is stopped; when the connection is restarted, the spooled messages are delivered. When using Direct Transport, the Non-Persistent messages are not spooled for consumers when the connection is stopped and they are discarded.

  • Connection.close()—Closes the connection.
原文地址:https://www.cnblogs.com/cathygx/p/13494952.html