我需要测试包含标题的消息,所以我需要使用 MessageBuilder,但我无法序列化。
我尝试在生产者道具上添加序列化设置,但没有奏效。
有人能帮我吗?
这个错误:
org.apache.kafka.common.errors.SerializationException: Can't convert value of class org.springframework.messaging.support.GenericMessage to class org.apache.kafka.common.serialization.StringSerializer specified in value.serializer
Run Code Online (Sandbox Code Playgroud)
我的测试班:
public class TransactionMastercardAdapterTest extends AbstractTest{
@Autowired
private KafkaTemplate<String, Message<String>> template;
@ClassRule
public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1);
@BeforeClass
public static void setUp() {
System.setProperty("spring.kafka.bootstrap-servers", embeddedKafka.getBrokersAsString());
System.setProperty("spring.cloud.stream.kafka.binder.zkNodes", embeddedKafka.getZookeeperConnectionString());
}
@Test
public void sendTransactionCommandTest(){
String payload = "{\"o2oTransactionId\" : \"" + UUID.randomUUID().toString().toUpperCase() + "\","
+ "\"cardId\" : \"11\","
+ "\"transactionId\" : \"20110405123456\","
+ "\"amount\" : 200.59,"
+ "\"partnerId\" : \"11\"}";
Map<String, Object> …Run Code Online (Sandbox Code Playgroud) apache-kafka kafka-producer-api spring-cloud-stream spring-kafka
我正在尝试使用hyst但是当调用save方法时,它会使用resttemplate发布一个帖子,它会出现以下异常:
未找到备用方法:com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException断路器([类com.wnb.mastercard.domain.enroll.EnrollCommand])
有人能帮我吗?
@Component
public class EnrollRepositoryRest {
@Autowired
private RestTemplate template;
@Value("${beblue-card-enroll.url}")
private String url;
public Enroll getEnrollByCardId(String cardId) {
Enroll[] enroll = template.getForObject(url + "cardEnroll/enroll/" + cardId, Enroll[].class);
return enroll[0];
}
@HystrixCommand(fallbackMethod = "breaker")
public void save(EnrollCommand command) {
template.postForObject(url + "/cardEnroll/enroll", command, EnrollCommand.class);
}
public String breaker() {
System.out.println("HYSTRIX EXECUTADO");
return "Hystrix is Ok";
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试恢复我的对象的最后一个状态,但是这个子选择不起作用,我已经看到新版本的cassandra db支持聚合操作和子查询.
select * from event_store
where event_version = (select max(event_version) from event_store)
ALLOW FILTERING;
Run Code Online (Sandbox Code Playgroud)
语法异常:第1:49行输入'select'没有可行的选择(...来自event_version = [(] select ...)的event_store
很抱歉这个问题过于通用,但有人有一些关于如何使用kafka嵌入式执行生产者和消费者测试的教程或指南.我已经尝试了几个,但有几个版本的依赖项,没有实际工作= /
我正在使用spring cloud stream kafka.
我对一个关闭的端点运行调用,但是hystrix没有执行回退方法,并抛出异常:
java.util.concurrent.ExecutionException: org.springframework.web.client.ResourceAccessException:
I/O error on GET request for "http://localhost:8080/wallet/customers/100/cards/": Conexão recusada (Connection refused); nested exception is java.net.ConnectException: Conexão recusada (Connection refused)
Run Code Online (Sandbox Code Playgroud)
有人知道是否缺少任何配置?
我的主要
@EnableCircuitBreaker
@SpringBootApplication
public class WalletPaymentApplication {
public static void main(String[] args) {
SpringApplication.run(WalletPaymentApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
和我的服务:
public PaymentMethodsData setUpPaymentMethods(String customerId) {
return new PaymentMethodsData(getCardList(customerId));
}
@HystrixCommand(fallbackMethod = "getCardListCircuitBreaker")
public List<SummaryCardData> getCardList(String customerId) {
return template.getForObject(configureUrl(cardUrl), CardRows.class, customerId).getRows();
}
public List<SummaryCardData> getCardListCircuitBreaker(String customerId){
return new ArrayList<>();
}
Run Code Online (Sandbox Code Playgroud) 我试图将 Spring 安全配置为仅阻止对 swagger 的请求,但是它阻止了所有 url。有谁知道如何只锁定 swagger 的 url 而其余的都不安全?
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests().anyRequest().permitAll()
.and()
.authorizeRequests()
.antMatchers("/swagger*/**").authenticated();
http.httpBasic();
}
Run Code Online (Sandbox Code Playgroud)