Skip to main content
Version: 4.6.1-saas

Quick Start

Get started with NetFUNNEL 4 Java Agent in 5-10 minutes with this quick start guide.

What You Can Do with This Guide

  • URL-Triggered Integration: Automatic queue control based on trigger rules
Choosing Integration Method

For detailed information about integration methods, refer to the Integration Methods Overview.


Prerequisites

  • NetFUNNEL console access
  • Java project (Spring Boot 3.x or higher)
  • Java 1.7 or higher

Step 1: Get Client ID and Secret Key

  1. Go to NetFUNNEL Console
  2. Click the profile icon in the top right corner
  3. Select the Integration Credentials menu
  4. Copy Client ID and Secret Key

Step 2: Install Library

Gradle (Kotlin DSL)

Add the following dependencies to build.gradle.kts:

implementation(files("libs/netfunnel-agent.jar"))
implementation("com.google.code.gson:gson:2.9.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

Gradle (Groovy DSL)

Add the following dependencies to build.gradle:

implementation files('libs/netfunnel-agent.jar')
implementation 'com.google.code.gson:gson:2.9.1'
// When using Java
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'

Maven

Add the following dependencies to pom.xml:

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.15.2</version>
</dependency>

Add the netfunnel-agent.jar file to the libs folder and add the following configuration:

<dependency>
<groupId>com.stclab</groupId>
<artifactId>netfunnel-agent</artifactId>
<version>4.0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/netfunnel-agent.jar</systemPath>
</dependency>

Step 3: Apply Interceptor or Filter

Select and apply only one of Interceptor or Filter according to your project structure.

Interceptor Method

1. Create Interceptor

import com.stclab.Netfunnel;
import com.stclab.servlet.NetFunnelServletService;
import com.stclab.utils.NetFunnelInitialize;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class NetFunnelInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
NetFunnelInitialize config = NetFunnelInitialize.Companion.builder()
.clientId("{{CLIENT_ID}}") // Client ID obtained in Step 1
.secretKey("{{SECRET_KEY}}") // Secret Key obtained in Step 1
.build();
Netfunnel netfunnel = new Netfunnel(config, new NetFunnelServletService(request, response), null, null);
return netfunnel.run();
}
}

2. Register Interceptor

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
private final NetFunnelInterceptor netFunnelInterceptor;

@Autowired
public WebConfig(NetFunnelInterceptor netFunnelInterceptor) {
this.netFunnelInterceptor = netFunnelInterceptor;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(netFunnelInterceptor)
.addPathPatterns("/**");
}
}

Filter Method

1. Create Filter

import com.stclab.Netfunnel;
import com.stclab.servlet.NetFunnelServletService;
import com.stclab.utils.NetFunnelInitialize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class NetFunnelFilter implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
NetFunnelInitialize config = NetFunnelInitialize.Companion.builder()
.clientId("{{CLIENT_ID}}") // Client ID obtained in Step 1
.secretKey("{{SECRET_KEY}}") // Secret Key obtained in Step 1
.build();
Netfunnel netfunnel = new Netfunnel(config, new NetFunnelServletService(request, response), null, null);
if (!netfunnel.run()) {
return;
}
chain.doFilter(servletRequest, servletResponse);
}
}

2. Register Filter

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {
@Bean
public FilterRegistrationBean<Filter> filterRegistrationBean() {
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
registration.setFilter(new NetFunnelFilter());
registration.addUrlPatterns("/*");
registration.setOrder(1);
return registration;
}
}

Step 4: Configure Trigger Rules

  1. Create Segment in Console:

    • Go to NetFUNNEL Console → ProjectsSegmentCreate Segment
    • Enter segment name
    • Set entry status to Waiting
    • Set entry limit to 0 (for testing)
  2. Configure Trigger Rules:

    • Add rules in the Trigger Rules section
    • Validator: URL
    • Component: Path or URL
    • Match: Equals, Contains, StartsWith, EndsWith, etc.
    • Value: Enter URL path to apply (e.g., /checkout, /login)

Step 5: Test

  1. Test Trigger Rules: Use the console's trigger rule test feature to verify that URLs match the rules
  2. Verify Waiting Room: Verify that the waiting room is displayed when accessing URLs that match the rules
  3. Verify Entry: Increase the entry limit to verify that entry works correctly

Need Help?

  • Troubleshooting: Common issues and solutions
  • API Reference: Complete function specifications
  • Verify that the project/segment keys in the console match exactly