Skip to content

Commit

Permalink
Add log-size property to soap methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Forbiddensequence authored and ihostage committed Apr 27, 2024
1 parent c8964c8 commit eca4e63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public class MyServiceImpl implements MyService {

* Configure SOAP client `play.soap.services.<SERVICE_CLASS>.singleton` as Singleton for better performance. *Warning*: It can be **NOT** thread-safe. More details see on [CXF docs](http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe%3F) (Default value `false`)

* Configure max log size of you soap-client `play.soap.services.<SERVICE_CLASS>.log-size` (Default value 48 kB). When you use log-size more than 128 kbytes CXF creates temporary files that contains messages, and CXF deletes files by itself.

```HOCON
lagom.circuit-breaker {
default.exception-whitelist = [
Expand All @@ -154,6 +156,7 @@ play.soap.services {
address = "http://domain:PORT/service"
browser-type = "Lagom MyService"
singleton: false
log-size : 1MB
breaker = {
call-timeout = 10s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.github.config4k.extract
import javassist.util.proxy.MethodHandler
import javassist.util.proxy.ProxyFactory
import mu.KotlinLogging
import org.apache.cxf.interceptor.AbstractLoggingInterceptor
import org.apache.cxf.transport.http.HTTPConduit
import play.soap.PlayJaxWsClientProxy
import play.soap.PlaySoapClient
Expand Down Expand Up @@ -86,6 +87,7 @@ constructor(
private val invokeHandlers: List<InvokeHandler<P>>
private val port: P
private val isSingleton: Boolean
private val logSize: Int?

init {
val globalConfig = configProvider.get()
Expand All @@ -98,6 +100,7 @@ constructor(
this.soapHandlers = arrayOf(*soapHandlers).plus(handlers)
this.invokeHandlers = this@ServiceProviderImpl.invokeHandlers.plus(invokeMethodHandlers)
this.isSingleton = if (config.hasPath("singleton")) config.getBoolean("singleton") else false
this.logSize = if (config.hasPath("log-size")) config.getBytes("log-size").toInt() else null
this.port = if (isSingleton) createPort() else Unit as P
}

Expand Down Expand Up @@ -166,6 +169,10 @@ constructor(
val port = getPortMethod.invoke(service, soapHandlers as Any) as P
val proxy = Proxy.getInvocationHandler(port) as PlayJaxWsClientProxy
val httpClientPolicy = (proxy.client.conduit as HTTPConduit).client
if (logSize != null) {
proxy.client.inInterceptors.filterIsInstance<AbstractLoggingInterceptor>().forEach { it.limit = logSize }
proxy.client.outInterceptors.filterIsInstance<AbstractLoggingInterceptor>().forEach { it.limit = logSize }
}
httpClientPolicy.browserType = config.extract("browser-type") ?: "lagom"
afterInit(port)
return port
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.atconsulting.tele2.lkb2c.handler
package org.taymyr.lagom.soap.handler

import org.taymyr.lagom.soap.InvokeHandler
import javax.xml.ws.BindingProvider
Expand Down

0 comments on commit eca4e63

Please sign in to comment.