- Neuron ESB
- Samples and Walkthroughs
- Custom Adapters
- Log Adapter
Writing custom adapters for Neuron is very common. This sample adapter demonstrates how to write an adapter that subscribes to messages from the ESB and writes the contents of those messages to the Neuron log files and Windows Event Viewer. For more information about writing custom adapters, please see the Adapter Framework sample and documentation.
Running the Sample
Open the Sample
To open this sample, see the topic Using the Neuron Samples and select the Log Adapter sample.
Note: This sample does not open a Neuron ESB Configuration. It only opens a Visual Studio project.
Configure the Sample
When launching this sample from the Samples Explorer, a Visual Studio project is opened. The references in this project need to be verified and the project needs to be built.
- In Visual Studio, expand the References list in the Solution Explorer.
- There needs to be six references to Neuron ESB Assemblies in this list:
- If the references show an error, remove them and re-add them from the Neuron program files installation directory (C:\Program Files\Neudesic\Neuron ESB v3\DEFAULT).
- Build the solution.
- Copy the adapter assembly Neuron.Esb.Adapters.LogAdapter.dll from the build output folder (C:\Program Files\Neudesic\Neuron ESB v3\Samples\CustomAdapters\LogAdapter\bin\Debug) to the Adapters folder in the Neuron program files installation directory (C:\Program Files\Neudesic\Neuron ESB v3\DEFAULT\Adapters).
Create a new Neuron Configuration
- If Neuron ESB Explorer is already opened, close it and re-open it, and create a new Neuron Configuration.
- Navigate to Messaging->Publish and Subscribe->Topics and create a new topic called LogTopic.
- Navigate to Messaging->Publish and Subscribe->Publishers and create a new publisher called LogPublisher, and set the subscription to the topic LogTopic (Send).
- Navigate to Messaging->Publish and Subscribe->Subscribers and create a new subscriber called LogSubscriber, and set the subscription to the topic LogTopic (Receive).
- Navigate to Connections->Connection Methods->Adapter Registration.
- Click the New button to register a new adapter:
- Set the Name to LogAdapter and select Log Adapter from the Adapter dropdown list:
- Click the Apply button.
- Navigate to Connections->Endpoints->Adapter Endpoints and click the New button.
- Set the Name to LogAdapterEndpoint, select LogAdapter from the Adapter dropdown list, select the Mode Subscribe and the Party Id LogSubscriber:
- Select the Proper
ties tab. This sample only has one property that it uses – Error Level. Set this to reflect which error level you want the messages reported in the log files and Windows Event Viewer. However, the other properties listed are provided as examples of properties of custom adapters (changes these values will be ignored by this sample adapter):
- Click the Apply button.
- Save the Neuron Configuration by clicking File->Save, then create a new Folder and navigate into that folder:
- Click the Select button and the configuration will be saved.
- Configure the Neuron ESB Service to run the new configuration by clicking the Configure Server button:
- Set the ESB Configuration Folder to the folder containing the configuration you just saved:
- Click Save, then restart the Neuron ESB Service:
Run the Sample
- In Neuron ESB Explorer, open a test client from Tools->Test Client->1 Test Client.
- Select LogPublisher from the Party Id dropdown list and click the Connect button:
- Click the Send tab and enter any message. Click the Send button:
- Open the Windows Event Viewer and navigate to Applications and Services Logs->Neuron ESB v3. You will see an entry from the adapter in the Neuron event logs:
- Using Windows Explorer, navigate to the Neuron log files (C:\Program Files\Neudesic\Neuron ESB v3\logs\DEFAULT) and select the most recently created folder.
- Open the log file for the LogAdapterEndpoint (i.e. Enterprise_Adapter Endpoint_LogAdapterEndpoint-2013-01-21.log).
- You will see something similar to this. Note the last line which is the Warning log message from the adapter:
ESB Trace Log - Machine: JKLUG03 - Trace level: Error+Warning+Info+Verbose 2013-01-21 06:01:50.226-08:00 3 info Starting 2013-01-21 06:01:50.226-08:00 3 info Service Id = 6dc1ed90-4e90-41d2-8a1e-d3e97986eda8 2013-01-21 06:01:50.226-08:00 3 info Created proxy to control service 2013-01-21 06:01:50.226-08:00 3 info Retrieved configuration from control service 2013-01-21 06:01:50.232-08:00 3 info Starting heartbeat thread 2013-01-21 06:01:50.237-08:00 3 info Adapter policy: Default 2013-01-21 06:01:50.238-08:00 3 info Heartbeat thread is waiting for initialization to complete 2013-01-21 06:01:50.238-08:00 3 info Heartbeat thread is active 2013-01-21 06:01:50.243-08:00 3 info Setting up adapter endpoint LogAdapterEndpoint 2013-01-21 06:01:50.245-08:00 4 verbose Running under service identity 2013-01-21 06:01:50.245-08:00 3 info Loading adapter LogAdapter 2013-01-21 06:01:50.308-08:00 3 info Configuring adapter, mode=Subscribe 2013-01-21 06:01:50.323-08:00 3 info Property Level = Warning 2013-01-21 06:01:50.323-08:00 3 info Property AuditOnFailure = False 2013-01-21 06:01:50.324-08:00 3 info Property PublishTopic = 2013-01-21 06:01:50.324-08:00 3 info Property PollingInterval = 10 2013-01-21 06:01:50.324-08:00 3 info Property ErrorMode = Error 2013-01-21 06:01:50.324-08:00 3 info Property ErrorHandling = StopPollingOnError 2013-01-21 06:01:50.327-08:00 3 info Connecting party LogSubscriber 2013-01-21 06:01:51.254-08:00 3 info Connecting to adapter 2013-01-21 06:01:51.266-08:00 3 info Opened direct connection at net.pipe://localhost/neuron/DEFAULT/direct/adapter/LogAdapterEndpoint 2013-01-21 06:01:51.266-08:00 3 info Started 2013-01-21 06:04:34.430-08:00 4 verbose Received Message. MessageId 4c6ed16f-13fa-4003-bbad-512919052211 Topic LogTopic 2013-01-21 06:04:34.434-08:00 2 warning <test>This is a test message</test>