Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to start the IPF XDS tutorial using Spring Boot

63 views
Skip to first unread message

Bo Vane

unread,
Jun 12, 2024, 4:35:14 AM6/12/24
to ipf-user
Hello everyone
As I want to integrate the XDS tutorial into a Spring Boot project, I need to transform its startup method. I don't want to start Tomcat directly from Server.groovy. Here, I would like to seek everyone's help. (PS: I'm not familiar with Apache Camel and Groovy)

In order to integrate the XDS tutorial into Spring Boot, I made the following attempts:
First, I tried to start the XDS tutorial in a Spring Boot manner, so I converted the Beans configured in the context.xml to Java configuration.
My Configuration.java is as follows:
import org.apache.camel.spring.SpringCamelContext;
import org.openehealth.ipf.commons.audit.DefaultAuditContext;
import org.openehealth.ipf.commons.audit.queue.RecordingAuditMessageQueue;
import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InPayloadLoggerInterceptor;
import org.openehealth.ipf.commons.ihe.ws.cxf.payload.OutPayloadLoggerInterceptor;
import org.openehealth.ipf.tutorials.xds.DataStore;
import org.openehealth.ipf.tutorials.xds.Iti18RouteBuilder;
import org.openehealth.ipf.tutorials.xds.Iti4142RouteBuilder;
import org.openehealth.ipf.tutorials.xds.Iti43RouteBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource({"classpath:META-INF/cxf/cxf.xml", "classpath:META-INF/cxf/cxf-servlet.xml"})
public class XdsCamelContextConfig {
@Bean
public DefaultAuditContext auditContext(RecordingAuditMessageQueue mockedSender) {
DefaultAuditContext auditContext = new DefaultAuditContext();
auditContext.setAuditEnabled(true);
auditContext.setAuditSourceId("sourceId");
auditContext.setAuditMessageQueue(mockedSender);
return auditContext;
}

@Bean
public RecordingAuditMessageQueue mockedSender() {
return new RecordingAuditMessageQueue();
}

@Bean
public DataStore dataStore() {
return new DataStore();
}
@Bean
public Iti4142RouteBuilder iti4142RouteBuilder() {
return new Iti4142RouteBuilder();
}

@Bean
public Iti43RouteBuilder iti43RouteBuilder() {
return new Iti43RouteBuilder();
}

@Bean
public Iti18RouteBuilder iti18RouteBuilder() {
return new Iti18RouteBuilder();
}

@Bean
public String logFileNamePrefix() {
return "/Users/bovane/Documents/hos-app/logs";
}
@Bean
public InPayloadLoggerInterceptor serverInLogger() {
return new InPayloadLoggerInterceptor("/Users/bovane/Documents/hos-app/logs/server-in.txt");
}

@Bean
public OutPayloadLoggerInterceptor serverOutLogger() {
return new OutPayloadLoggerInterceptor("/Users/bovane/Documents/hos-app/logs/server-out.txt");
}

@Bean
public SpringCamelContext camelContext() {
SpringCamelContext camelContext = new SpringCamelContext();
return camelContext;
}
}

Next, I directly started the XDSApplication, and its output shows that the routes written in the XDS tutorial have been started. However, when I tested using SOAP UI app, I encountered a 404 error. For example, when I sent a request to http://localhost:9091/xds-iti41, it returned a 404 error. I am not sure what the reason is. (However When I directly run Server.groovy, the same request can successfully register documents.) What should I do next to make modifications?  The application startup log is as follows

Picked up _JAVA_OPTIONS: -Djavax.xml.accessExternalSchema=all

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.2.RELEASE)

2024-06-12 16:00:21.120 INFO 51020 --- [ main] work.mediway.ihe.XDSApplication : Starting XDSApplication on MacPro with PID 51020 (/Users/bovane/Documents/GitHub/ihe-base/ihe-xds/target/classes started by bovane in /Users/bovane/Documents/GitHub/ihe-base)
2024-06-12 16:00:21.122 INFO 51020 --- [ main] work.mediway.ihe.XDSApplication : No active profile set, falling back to default profiles: default
2024-06-12 16:00:21.382 INFO 51020 --- [ main] o.o.i.c.c.config.ExtensionModuleFactory : Registering new extension module RegRepModelExtension defined in class org.openehealth.ipf.tutorials.xds.RegRepModelExtension
2024-06-12 16:00:21.433 INFO 51020 --- [ main] o.o.i.c.c.config.ExtensionModuleFactory : Registering new extension module MappingExtension defined in class org.openehealth.ipf.commons.map.extend.MappingExtensionModule
2024-06-12 16:00:21.434 INFO 51020 --- [ main] o.o.i.c.c.config.ExtensionModuleFactory : Registering new extension module CoreExtension defined in class org.openehealth.ipf.platform.camel.core.extend.CoreExtensionModule
2024-06-12 16:00:23.069 INFO 51020 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9091 (http)
2024-06-12 16:00:23.080 INFO 51020 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2024-06-12 16:00:23.080 INFO 51020 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2024-06-12 16:00:23.187 INFO 51020 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2024-06-12 16:00:23.187 INFO 51020 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1631 ms
2024-06-12 16:00:24.663 INFO 51020 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2024-06-12 16:00:24.767 INFO 51020 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9091 (http) with context path ''
2024-06-12 16:00:25.467 INFO 51020 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {urn:ihe:iti:xds-b:2007}DocumentRepository_Service from WSDL: wsdl/iti43.wsdl
2024-06-12 16:00:26.012 INFO 51020 --- [ main] org.apache.cxf.endpoint.ServerImpl : Setting the server's publish address to be /xds-iti43
2024-06-12 16:00:26.045 INFO 51020 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {urn:ihe:iti:xds-b:2007}DocumentRegistry_Service from WSDL: wsdl/iti18.wsdl
2024-06-12 16:00:26.102 INFO 51020 --- [ main] org.apache.cxf.endpoint.ServerImpl : Setting the server's publish address to be /xds-iti18
2024-06-12 16:00:26.104 INFO 51020 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {urn:ihe:iti:xds-b:2007}DocumentRepository_Service from WSDL: wsdl/iti41.wsdl
2024-06-12 16:00:26.155 INFO 51020 --- [ main] org.apache.cxf.endpoint.ServerImpl : Setting the server's publish address to be /xds-iti41
2024-06-12 16:00:26.158 INFO 51020 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {urn:ihe:iti:xds-b:2007}DocumentRegistry_Service from WSDL: wsdl/iti42.wsdl
2024-06-12 16:00:26.174 INFO 51020 --- [ main] org.apache.cxf.endpoint.ServerImpl : Setting the server's publish address to be /xds-iti42
2024-06-12 16:00:26.177 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.21.3 (camel-1) is starting
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (started:34)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route1 (xds-iti43://xds-iti43)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route2 (xds-iti18://xds-iti18)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route3 (direct://convertToObjRefs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route4 (direct://findDocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route5 (direct://findSets)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route6 (direct://findFolders)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route7 (direct://getDocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route8 (direct://getFolders)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route9 (direct://getDocsAndAssocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route10 (direct://getFoldersForDoc)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route11 (direct://getRelatedDocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route12 (direct://getSets)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route13 (direct://getAssocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route14 (direct://getFolderAndContents)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route15 (direct://getSetAndContents)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route16 (xds-iti41://xds-iti41)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route17 (xds-iti42://xds-iti42)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route18 (direct://checkForAssociationToDeprecatedObject)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route19 (direct://checkPatientIds)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route20 (direct://checkHashAndSize)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route21 (direct://checkHash)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route22 (direct://makeDocsReReadable)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route23 (direct://storeDocs)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route24 (direct://updateDocEntriesFromProvide)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route25 (direct://storeDocEntriesFromRegister)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route26 (direct://storeFolders)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route27 (direct://storeSubmissionSet)
2024-06-12 16:00:26.520 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route28 (direct://store)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route29 (direct://storeAssociations)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route30 (direct://checkReplace)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route31 (direct://copyFolderMembership)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route32 (direct://deprecateTargetDocs)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route33 (direct://deprecateDocEntry)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route34 (direct://updateTime)
2024-06-12 16:00:26.521 INFO 51020 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.21.3 (camel-1) started in 1s403ms (build:21ms init:1s39ms start:343ms)
2024-06-12 16:00:26.522 INFO 51020 --- [ main] o.o.i.commons.core.config.ContextFacade : Re-initializing the registry
2024-06-12 16:00:26.522 INFO 51020 --- [ main] c.s.c.c.SpringConfigurationPostProcessor : Number of extension beans: 1
2024-06-12 16:00:26.539 INFO 51020 --- [ main] work.mediway.ihe.XDSApplication : Started XDSApplication in 5.815 seconds (JVM running for 6.75)
2024-06-12 16:00:26.709 INFO 51020 --- [1)-172.20.6.163] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-06-12 16:00:26.709 INFO 51020 --- [1)-172.20.6.163] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2024-06-12 16:00:26.710 INFO 51020 --- [1)-172.20.6.163] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms


I don't know if the CXF service is not started, and I don't know how to view Camel routes. How can I check these services? I don't know how to troubleshoot the issue.

My full pom.xml are as follows (PS: parent pom.xml)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/>
</parent>
<groupId>work.mediway.ihe</groupId>
<artifactId>ihe-base</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>ihe-xds</module>
<module>ihe-ct</module>
</modules>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hutool.version>5.8.12</hutool.version>
<lombok.version>1.18.20</lombok.version>
<javax.version>1.3.2</javax.version>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax.version}</version>
</dependency>
</dependencies>

</project>

Then, 
XDS module pom.xml 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>work.mediway.ihe</groupId>
<artifactId>ihe-base</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>ihe-xds</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<ipf.version>4.8-m5</ipf.version>
<camel-version>3.21.3</camel-version>
<groovy.version>3.0.8</groovy.version>
</properties>
<!-- IPF 框架依赖管理 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openehealth.ipf</groupId>
<artifactId>ipf-dependencies</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${ipf.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- common -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<!-- SpringBoot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>


<!-- IPF -->
<dependency>
<groupId>org.openehealth.ipf.boot</groupId>
<artifactId>ipf-atna-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.openehealth.ipf.boot</groupId>
<artifactId>ipf-xds-spring-boot-starter</artifactId>
</dependency>


<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xds</artifactId>
<classifier>tests</classifier>
<version>${ipf.version}</version>
</dependency>


<!-- some test-jar for xds -->
<dependency>
<groupId>org.openehealth.ipf.platform-camel</groupId>
<artifactId>ipf-platform-camel-ihe-xds</artifactId>
<version>${ipf.version}</version>
<type>test-jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.openehealth.ipf.platform-camel</groupId>
<artifactId>ipf-platform-camel-ihe-ws</artifactId>
<version>${ipf.version}</version>
<type>test-jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-ws</artifactId>
<version>${ipf.version}</version>
<type>test-jar</type>
</dependency>

<!-- Groovy -->

<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel-version}</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel-version}</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-xml</artifactId>
<version>${camel-version}</version>
</dependency>

<!-- Dependencies for test -->
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xds</artifactId>
<version>${ipf.version}</version>
<type>test-jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-core</artifactId>
<version>${ipf.version}</version>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
<!--
Add build-info.properties to generated artifact
https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/reference/html/howto-build.html#howto-build-info
-->
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

My repository code address is https://github.com/bovane/ihe-base.git. The corresponding branch is dev-boot. If possible, could you please help take a look at the code? I think the possible issue may be with my configuration file, but I don't know how to correct it.  Thank you very much 😊

Best Regards
Bo




Thomas Papke

unread,
Jun 12, 2024, 2:28:20 PM6/12/24
to ipf-user
Hello Bo,

the following XDS registry might be blueprint where you could have a look howto configure IPF XDS in a spring boot context:


In case you want to stay on spring boot 2.x, you can have a look at an older tag: https://github.com/oehf/xds-registry-to-fhir/tree/v0.1

In context of the camel cxf spring boot starter, the XDS services are listed under the "/services" path. So for the demo deployment of the XDS registry project, you see the list on http://xds.thopap.de:8081/services , so maybe you can try in your ITI-41 with   http://localhost:9091/services/xds-iti41

The configuration of the default context path ("/services") where the CXF servlet listen for request can be configured in context of spring boot (see https://cxf.apache.org/docs/springboot.html#SpringBoot-AdditionalConfiguration for details).

Best regards,
Thomas

Bo Vane

unread,
Jun 13, 2024, 9:02:05 AM6/13/24
to ipf-user
Hello Thomas
Thank you very much for your advice. I have been able to find the XDS service, but I still cannot successfully start tutorials XDS in the SpringBoot way. I use XDS-related services in the IPF framework to deal with IHE evaluations. Therefore, I may need to do some secondary development work on the XDS tutorial you have written.

For example, defining my own processor, I encountered some issues in this process. For instance, I want to customize a Processor to handle audit information. Therefore, I want to use RecordingAuditMessageQueue as the audit information configuration. So, I instantiate it as a bean in context.xml and reference this bean in the Audit Context. But I don't know how to use it. I have customized a MyProcessor class, and my code is as follows. When I access my custom MyProcessor, I get a 500 NULL pointer exception. How should I access RecordingAuditMessageQueue? (PS: I directly started Server.groovy) Hope you can give me some advice ‼️ 😍

Best Regards
Bo
===========================================
configuration context.xml 

截屏2024-06-08 14.09.20.png


My processor is as follows

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.openehealth.ipf.commons.audit.model.AuditMessage;
import org.openehealth.ipf.commons.audit.queue.RecordingAuditMessageQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* @author bovane bova...@gmial.com
* @create 2024/6/13
*/
@Component
public class MyProcessor implements Processor {

protected Logger log = LoggerFactory.getLogger(getClass());

private RecordingAuditMessageQueue auditMessageQueue;

@Autowired
public MyProcessor(RecordingAuditMessageQueue auditMessageQueue) {
this.auditMessageQueue = auditMessageQueue;
}

@Override
public void process(Exchange exchange) {
log.warn("test processor");
List<AuditMessage> auditMessages = auditMessageQueue.getMessages(); // 500 null pointer
auditMessages.forEach(auditMessage -> log.warn(auditMessage.toString()));
}
}

T. Papke

unread,
Jun 13, 2024, 12:47:09 PM6/13/24
to ipf-...@googlegroups.com
Hello Bo,

"So, I instantiate it as a bean in context.xml and reference this bean in the Audit Context. But I don't know how to use it."

- First a recommendation: Prevent mixing annotation and xml spring configuration. Annotations are much easier.
- You seems to manually declare a lot of IPF configuration (e.g. the auditContext configuration), which are already handled by the ipf spring boot starter's - e.g. https://oehf.github.io/ipf-docs/docs/boot-atna/ and https://oehf.github.io/ipf-docs/docs/boot-xds/) - these starter's will handle most of the things for you, you just need to configure it (application.properties).
- If you want to implement a custom ATNA logger / processor (to do whatever you want), you e.g. simply define a bean (depending on you needs) which implement the AuditTransmissionProtocol (like seen here https://github.com/oehf/xds-registry-to-fhir/blob/main/src/main/java/org/openehealth/app/xdstofhir/registry/audit/RecentATNAEvents.java#L16) or e.g. also implement a AuditMessageQueue bean - the ipf Atna spring boot starter will do the configuration for you (don't forget the property for enable atna as mentioned https://oehf.github.io/ipf-docs/docs/boot-atna/), you don't need do define a auditContext manual. If you want to use the RecordingMessageQueue, simply create a instance. If you get a NPE in your "MyProcessor": is this bean also created by spring or have you manually create the instance?

"I directly started Server.groovy"
- in context of a spring boot application, i recommend to use the "@SpringBootTest", which will start the embedded tomcat for you (https://github.com/oehf/xds-registry-to-fhir/blob/main/src/test/java/org/openehealth/app/xdstofhir/registry/XdsToFhirApplicationIT.java#L43)

Best regards,
Thomas

--
You received this message because you are subscribed to a topic in the Google Groups "ipf-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ipf-user/MAxD1QiPvrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ipf-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ipf-user/9ec64f63-4f98-4b95-967a-66ed9237cb12n%40googlegroups.com.
Message has been deleted

Bo Vane

unread,
Jun 15, 2024, 9:26:08 AM6/15/24
to ipf-user
Hello Thomas,

Thank you very much for your advice. I have re-modified XdsApplicationConfig, keeping only the beans for instantiating routes, such as Iti4142RouteBuilder, Iti43RouteBuilder, etc. I have moved the audit-related configurations to application.properties. And added camel-spring-boot-starter dependency, so I could successfully start the XDS tutorial in SpringBoot way. However, when I configured ipf.atna.audit-queue-class=org.openehealth.ipf.commons.audit.queue.RecordingAuditMessageQueue in the application.properties, how should I use it? For example, if I just want to print the content of the audit message queue, how should I do it?


"If you get a NPE in your "MyProcessor": is this bean also created by spring or have you manually create the instance?"

I have manually created my calling method, and I don't know how to make Spring create MyProcessor for me. What is the correct way to use it?

截屏2024-06-15 21.01.04.png
截屏2024-06-15 21.02.46.png

Best regards,
Bo

Bo Vane

unread,
Jun 17, 2024, 5:25:18 AM6/17/24
to ipf-user
Dear ipf-developer's

Thank you very much for your help. I have been able to solve the issues I raised and add additional functionalities to the XDS tutorial project, such as persisting audit information to the database and so on. Without your enthusiastic assistance, I wouldn't have been able to get started with the XDS tutorial project. Wishing you good health and all the best in everything.💗

Best Regards,
Bo 
Reply all
Reply to author
Forward
0 new messages