Session session = connection.createSession(paramA,paramB);参数解析

Session session = connection.createSession(paramA,paramB);

paramA是设置事务,paramB是设置acknowledgment mode 

paramA 取值有:

1、true:支持事务

为true时:paramB的值忽略, acknowledgment mode被jms服务器设置为SESSION_TRANSACTED 。  

2、false:不支持事务 

为false时:paramB的值可为Session.AUTO_ACKNOWLEDGE、Session.CLIENT_ACKNOWLEDGE、DUPS_OK_ACKNOWLEDGE其中一个。

paramB 取值有:

1、Session.AUTO_ACKNOWLEDGE:为自动确认,客户端发送和接收消息不需要做额外的工作。

2、Session.CLIENT_ACKNOWLEDGE:为客户端确认。客户端接收到消息后,必须调用javax.jms.Message的acknowledge方法。jms服务器才会删除消息。 

3、DUPS_OK_ACKNOWLEDGE:允许副本的确认模式。一旦接收方应用程序的方法调用从处理消息处返回,会话对象就会确认消息的接收;而且允许重复确认。在需要考虑资源使用时,这种模式非常有效。

4、SESSION_TRANSACTED

 

---【转】

protected void configure(HttpSecurity http) throws Exception { // 禁用CSRF保护 http.csrf().disable(); // 自定义认证提供者 - 参数校验 AuthenticationProvider paramValidationProvider = new AuthenticationProvider() { @Override public Authentication authenticate(Authentication authentication) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // 仅对特定请求进行参数校验 if ("/oauth/app/verifyCode/token".equals(request.getRequestURI()) && "POST".equalsIgnoreCase(request.getMethod())) { List<String> errors = new ArrayList<>(); // 使用静态常量进行参数校验 PARAM_RULES.forEach((param, errorMsg) -> { String value = request.getParameter(param); if (value == null || value.trim().isEmpty()) { errors.add(errorMsg); } }); // 抛出参数校验异常 if (!errors.isEmpty()) { throw new BadCredentialsException(String.join("; ", errors)); } } return authentication; } @Override public boolean supports(Class<?> authentication) { return true; // 支持所有认证类型 } }; // 配置认证提供者和异常处理 http.authenticationProvider(paramValidationProvider) .authorizeRequests() .anyRequest().authenticated() .and() .exceptionHandling() .authenticationEntryPoint((request, response, authException) -> { // 处理参数校验异常 if (authException instanceof BadCredentialsException) { response.setStatus(HttpStatus.BAD_REQUEST.value()); response.getWriter().write(authException.getMessage()); } else { // 其他认证异常处理 response.sendError(HttpStatus.UNAUTHORIZED.value(), "未认证"); } }); // 表单登录配置 http.formLogin() .loginProcessingUrl("/user/login") .successHandler(authenticationSuccessHandler) .failureHandler(authenticationFailureHandler) .permitAll() .and() .logout() .logoutSuccessUrl("/login.html") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()) .addLogoutHandler(oauthLogoutHandler) .clearAuthentication(true); // 应用自定义安全配置 http.apply(validateCodeSecurityConfig) .and() .apply(phoneOrAccountAuthenticationSecurityConfig) .and() .apply(unionIdAuthenticationSecurityConfig); // 解决不允许显示在iframe的问题 http.headers().frameOptions().disable(); http.headers().cacheControl(); // 关键整合点:配置无状态会话策略 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); } 要是不是参数为空是参数根本没传呢 增加判断
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值