Connections
Connections are frequently used objects in every IM instance.
For example, the pricefx connection defines how to connect to a partition. You need to set the username, password, partition, URI etc. in order to connect. This way all the credentials and connection details are contained within the “connection object” and users can connect without the need to re-enter credentials again.
Multiple connections currently exist for various needs. We will explore how to create and use these connections.
How to Define Connection
There are several ways to define a connection:
Create connection via PlatformManager – Preferred way for provisioned instances. For details see Connections.
Create connection in camel-context.xml – Preferred way for manual instances. Open camel-context.xml file (or beans.xml for older instance) and write the definition, for example:
<bean id="conn123" class="net.pricefx.integration.component.rest.domain.connection.OAuth2Connection"> <property name="url" value="https://thecompany.com"/> <property name="authUrl" value="https://login.thecompany.com/v2/token"/> <property name="clientId" value="21314421214"/> <property name="clientSecret" value="qwe.#@!#!dd"/> <property name="authRequestTemplate" value="{"grant_type": "client_credentials","client_id": "::clientId","client_secret":"::clientSecret"}"/> </bean>
This example creates an Oauth connection with the name
conn123
.
Properties and connection classes are subject to change. The best way to check is to open the integration-manager codebase, find the classConnection
and see all subclasses.Create connection via application.properties – Works only for connections to Pricefx. You can create a connection by setting the following properties:
integration.pfx.url= integration.pfx.username= integration.pfx.partition= integration.pfx.password= integration.pfx.debug=false
If you fill in the fields, a default connection named
pricefx
will be created. You can use such connection throughout the application.
For more information see PfxClient.
How to Use Connection
Connections are used in components.
Example
This example shows how to use a connection in the pfx-rest component.
First, define a connection in camel-context.xml file:
<bean id="conn123" class="net.pricefx.integration.component.rest.domain.connection.OAuth2Connection">
<property name="url" value="https://thecompany.com"/>
<property name="authUrl" value="https://login.thecompany.com/v2/token"/>
<property name="clientId" value="21314421214"/>
<property name="clientSecret" value="qwe.#@!#!dd"/>
<property name="authRequestTemplate" value="{"grant_type": "client_credentials","client_id": "::clientId","client_secret":"::clientSecret"}"/>
</bean>
Create a route and use the connection:
This way, the connection conn123
is used to get data from an external system.
Connection with SSL Certificate
Each connection can use a self-signed SSL certificate. The certificate must be stored in the configuration repository.
Option | Type | Description |
---|---|---|
| string | Name of the certificate. |
| enum | Specifies what type of certificate is contained in the body: |
| string | Certificate body in the X.509 pem format. |
By specifying the fields in the connection, the SSL certificate will be used in each call.
IntegrationManager version 5.8.0