- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.netflix.zuul.exception.ZuulException.<init>()
方法的一些代码示例,展示了ZuulException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZuulException.<init>()
方法的具体详情如下:
包路径:com.netflix.zuul.exception.ZuulException
类名称:ZuulException
方法名:<init>
[英]error message, status code and info about the cause
[中]错误消息、状态代码和有关原因的信息
代码示例来源:origin: Netflix/zuul
public void finish() throws RuntimeException {
try {
gzos.finish();
gzos.flush();
gzos.close();
}
catch (IOException ioEx) {
throw new ZuulException(ioEx, "Error finalizing the GzipOutputStream", true);
}
}
代码示例来源:origin: Netflix/zuul
private void handleExpect100Continue(ChannelHandlerContext ctx, HttpRequest req) {
if (HttpUtil.is100ContinueExpected(req)) {
final ChannelFuture f = ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE));
f.addListener((s) -> {
if (! s.isSuccess()) {
throw new ZuulException( s.cause(), "Failed while writing 100-continue response", true);
}
});
// Remove the Expect: 100-Continue header from request as we don't want to proxy it downstream.
req.headers().remove(HttpHeaderNames.EXPECT);
zuulRequest.getHeaders().remove(HttpHeaderNames.EXPECT.toString());
}
}
代码示例来源:origin: Netflix/zuul
public void finish() throws RuntimeException {
try {
gzos.finish();
gzos.flush();
gzos.close();
}
catch (IOException ioEx) {
throw new ZuulException(ioEx, "Error finalizing the GzipOutputStream", true);
}
}
代码示例来源:origin: Netflix/zuul
public void write(final HttpContent chunk) {
try {
write(chunk.content());
gzos.flush();
}
catch(IOException ioEx) {
throw new ZuulException(ioEx, "Error Gzipping response content chunk", true);
}
finally {
chunk.release();
}
}
代码示例来源:origin: Netflix/zuul
@Override
public HttpResponseMessage apply(HttpRequestMessage request) {
final SessionContext zuulCtx = request.getContext();
zuulCtx.setErrorResponseSent(true);
final String errMesg = "Missing Endpoint filter, name = " + name;
zuulCtx.setError(new ZuulException(errMesg, true));
LOG.error(errMesg);
return new HttpResponseMessageImpl(zuulCtx, request, 500);
}
代码示例来源:origin: Netflix/zuul
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
final String errMesg = String.format("Error writing %s to client", requestPart);
if (cause instanceof java.nio.channels.ClosedChannelException ||
cause instanceof Errors.NativeIoException) {
LOG.info(errMesg + " - client connection is closed.");
if (zuulRequest != null) {
zuulRequest.getContext().cancel();
StatusCategoryUtils.storeStatusCategoryIfNotAlreadyFailure(zuulRequest.getContext(), ZuulStatusCategory.FAILURE_CLIENT_CANCELLED);
}
}
else {
LOG.error(errMesg, cause);
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
}
代码示例来源:origin: Netflix/zuul
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof HttpResponse) {
promise.addListener((future) -> {
if (! future.isSuccess()) {
fireWriteError("response headers", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else if (msg instanceof HttpContent) {
promise.addListener((future) -> {
if (! future.isSuccess()) {
fireWriteError("response content", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else {
//should never happen
ReferenceCountUtil.release(msg);
throw new ZuulException("Attempt to write invalid content type to client: "+msg.getClass().getSimpleName(), true);
}
}
代码示例来源:origin: Netflix/zuul
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!ctx.channel().isActive()) {
ReferenceCountUtil.release(msg);
return;
}
if (msg instanceof HttpRequestMessage) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("request headers", future.cause(), ctx);
}
});
HttpRequestMessage zuulReq = (HttpRequestMessage) msg;
preWriteHook(ctx, zuulReq);
super.write(ctx, buildOriginHttpRequest(zuulReq), promise);
}
else if (msg instanceof HttpContent) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("request content chunk", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else {
//should never happen
ReferenceCountUtil.release(msg);
throw new ZuulException("Received invalid message from client", true);
}
}
代码示例来源:origin: Netflix/zuul
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
String errMesg = "Error while proxying " + requestPart + " to origin ";
if (edgeProxy != null) {
final ProxyEndpoint ep = edgeProxy;
edgeProxy = null;
errMesg += ep.getOrigin().getName();
ep.errorFromOrigin(cause);
}
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
代码示例来源:origin: Netflix/zuul
private void verifyOrigin(SessionContext context, HttpRequestMessage request, String restClientName, Origin primaryOrigin) {
if (primaryOrigin == null) {
// If no origin found then add specific error-cause metric tag, and throw an exception with 404 status.
context.set(CommonContextKeys.STATUS_CATGEORY, SUCCESS_LOCAL_NO_ROUTE);
String causeName = "RESTCLIENT_NOTFOUND";
originNotFound(context, causeName);
ZuulException ze = new ZuulException("No origin found for request. name=" + restClientName
+ ", uri=" + request.reconstructURI(), causeName);
ze.setStatusCode(404);
throw ze;
}
}
代码示例来源:origin: Netflix/zuul
private void handleExpect100Continue(ChannelHandlerContext ctx, HttpRequest req) {
if (HttpUtil.is100ContinueExpected(req)) {
final ChannelFuture f = ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE));
f.addListener((s) -> {
if (! s.isSuccess()) {
throw new ZuulException( s.cause(), "Failed while writing 100-continue response", true);
}
});
// Remove the Expect: 100-Continue header from request as we don't want to proxy it downstream.
req.headers().remove(HttpHeaderNames.EXPECT);
zuulRequest.getHeaders().remove(HttpHeaderNames.EXPECT.toString());
}
}
代码示例来源:origin: Netflix/zuul
public void write(final HttpContent chunk) {
try {
write(chunk.content());
gzos.flush();
}
catch(IOException ioEx) {
throw new ZuulException(ioEx, "Error Gzipping response content chunk", true);
}
finally {
chunk.release();
}
}
代码示例来源:origin: Netflix/zuul
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
final String errMesg = String.format("Error writing %s to client", requestPart);
if (cause instanceof java.nio.channels.ClosedChannelException ||
cause instanceof Errors.NativeIoException) {
LOG.info(errMesg + " - client connection is closed.");
if (zuulRequest != null) {
zuulRequest.getContext().cancel();
StatusCategoryUtils.storeStatusCategoryIfNotAlreadyFailure(zuulRequest.getContext(), ZuulStatusCategory.FAILURE_CLIENT_CANCELLED);
}
}
else {
LOG.error(errMesg, cause);
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
}
代码示例来源:origin: Netflix/zuul
@Override
public HttpResponseMessage apply(HttpRequestMessage request) {
final SessionContext zuulCtx = request.getContext();
zuulCtx.setErrorResponseSent(true);
final String errMesg = "Missing Endpoint filter, name = " + name;
zuulCtx.setError(new ZuulException(errMesg, true));
LOG.error(errMesg);
return new HttpResponseMessageImpl(zuulCtx, request, 500);
}
代码示例来源:origin: Netflix/zuul
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof HttpResponse) {
promise.addListener((future) -> {
if (! future.isSuccess()) {
fireWriteError("response headers", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else if (msg instanceof HttpContent) {
promise.addListener((future) -> {
if (! future.isSuccess()) {
fireWriteError("response content", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else {
//should never happen
ReferenceCountUtil.release(msg);
throw new ZuulException("Attempt to write invalid content type to client: "+msg.getClass().getSimpleName(), true);
}
}
代码示例来源:origin: Netflix/zuul
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof CompleteEvent) {
final CompleteReason reason = ((CompleteEvent) evt).getReason();
if ((reason != SESSION_COMPLETE) && (edgeProxy != null)) {
LOG.error("Origin request completed with reason other than COMPLETE: {}, {}",
reason.name(), ChannelUtils.channelInfoForLogging(ctx.channel()));
final ZuulException ze = new ZuulException("CompleteEvent", reason.name(), true);
edgeProxy.errorFromOrigin(ze);
}
// First let this event propagate along the pipeline, before cleaning vars from the channel.
// See channelWrite() where these vars are first set onto the channel.
try {
super.userEventTriggered(ctx, evt);
}
finally {
postCompleteHook(ctx, evt);
}
}
else if (evt instanceof IdleStateEvent) {
if (edgeProxy != null) {
LOG.error("Origin request received IDLE event: {}", ChannelUtils.channelInfoForLogging(ctx.channel()));
edgeProxy.errorFromOrigin(new OutboundException(READ_TIMEOUT, edgeProxy.getRequestAttempts()));
}
super.userEventTriggered(ctx, evt);
}
else {
super.userEventTriggered(ctx, evt);
}
}
代码示例来源:origin: Netflix/zuul
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!ctx.channel().isActive()) {
ReferenceCountUtil.release(msg);
return;
}
if (msg instanceof HttpRequestMessage) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("request headers", future.cause(), ctx);
}
});
HttpRequestMessage zuulReq = (HttpRequestMessage) msg;
preWriteHook(ctx, zuulReq);
super.write(ctx, buildOriginHttpRequest(zuulReq), promise);
}
else if (msg instanceof HttpContent) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("request content chunk", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
}
else {
//should never happen
ReferenceCountUtil.release(msg);
throw new ZuulException("Received invalid message from client", true);
}
}
代码示例来源:origin: Netflix/zuul
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
String errMesg = "Error while proxying " + requestPart + " to origin ";
if (edgeProxy != null) {
final ProxyEndpoint ep = edgeProxy;
edgeProxy = null;
errMesg += ep.getOrigin().getName();
ep.errorFromOrigin(cause);
}
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
代码示例来源:origin: Netflix/zuul
private void verifyOrigin(SessionContext context, HttpRequestMessage request, String restClientName, Origin primaryOrigin) {
if (primaryOrigin == null) {
// If no origin found then add specific error-cause metric tag, and throw an exception with 404 status.
context.set(CommonContextKeys.STATUS_CATGEORY, SUCCESS_LOCAL_NO_ROUTE);
String causeName = "RESTCLIENT_NOTFOUND";
originNotFound(context, causeName);
ZuulException ze = new ZuulException("No origin found for request. name=" + restClientName
+ ", uri=" + request.reconstructURI(), causeName);
ze.setStatusCode(404);
throw ze;
}
}
代码示例来源:origin: Netflix/zuul
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof CompleteEvent) {
final CompleteReason reason = ((CompleteEvent) evt).getReason();
if ((reason != SESSION_COMPLETE) && (edgeProxy != null)) {
LOG.error("Origin request completed with reason other than COMPLETE: {}, {}",
reason.name(), ChannelUtils.channelInfoForLogging(ctx.channel()));
final ZuulException ze = new ZuulException("CompleteEvent", reason.name(), true);
edgeProxy.errorFromOrigin(ze);
}
// First let this event propagate along the pipeline, before cleaning vars from the channel.
// See channelWrite() where these vars are first set onto the channel.
try {
super.userEventTriggered(ctx, evt);
}
finally {
postCompleteHook(ctx, evt);
}
}
else if (evt instanceof IdleStateEvent) {
if (edgeProxy != null) {
LOG.error("Origin request received IDLE event: {}", ChannelUtils.channelInfoForLogging(ctx.channel()));
edgeProxy.errorFromOrigin(new OutboundException(READ_TIMEOUT, edgeProxy.getRequestAttempts()));
}
super.userEventTriggered(ctx, evt);
}
else {
super.userEventTriggered(ctx, evt);
}
}
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 5年前关闭。 Improve t
使用 Zuul,我可以轻松定义在将请求转发到特定服务之前或之后激活的自定义过滤器。 有没有办法阻止请求在“预”过滤器级别转发,并立即将响应发送给客户端? 我知道“静态”过滤器可以做类似的事情,但我需要
通过 Zuul 向客户端发送请求时,Zuul 似乎更改了查询字符串。更具体地说,如果客户端应该收到一个 url 编码的查询字符串,Zuul 会对查询字符串进行一次解码。下面是一个具体的例子: 如果“h
我想在没有 Spring Boot 的情况下进行服务发现。 所以我下载了netflix项目example并且因为它的 gradle 项目我想使它成为 maven。 所以我创建了 maven 项目,导入
我正在开发一个 chromecast 发送器应用程序,我希望在其中启动 Netflix 并播放请求的电影。但是,我只能设法启动 Netflix 应用程序,但它不会加载视频,因为我不确定需要随请求发送哪
有什么原因可以解释为什么我在声明这样的伪接口(interface)方法时会出现编译错误(Body parameters cannot be used with form parameters): 1)
有什么原因可以解释为什么我在声明这样的伪接口(interface)方法时会出现编译错误(Body parameters cannot be used with form parameters): 1)
我一直在互联网上寻找有关将 spring-cloud-netflix eureka 服务器部署到 aws 的正确方法的指导。我们已经在使用 spring-cloud 和 nodejs 的微服务中使用了
我是 Netflix 开源项目的忠实粉丝。他们制作了一些非常酷的东西。 我已经设置了一个 Zuul,它工作正常。创建了各种过滤器,这些过滤器是动态加载和运行的。 我现在尝试做的是在过滤器中使用 Hys
我正在使用需要设置几个字段的 REST api。我的应用程序应始终将某些字段设置为相同的值。是否可以在带有 feign 定义(或其他地方)的界面中使这些值“硬编码”? 我的假声明看起来像这个例子。假设
我有以下简单服务: 交易核心服务和交易api服务。 transaction-api-service调用Transactions-core-service返回事务列表。 transaction-api-
我已经看到了关于如何为移动 Netflix 应用程序为 Netflix 进行电影深度链接的解决方案,但对于该应用程序的 Android TV 版本,这些相同的解决方案似乎不起作用。 我尝试过使用带有
使用路标 1.2: String authUrl = provider.retrieveRequestToken( consumer, callbackUrl ); Netflix API 响应:
我已经在 Eureka 服务器中注册了 UI 和后端应用程序。它已启动并正在运行(两个应用程序)。配置zuul application.yml: zuul: sensitive-headers:
我们的服务目前使用 spring cloud netflix zuul 作为我们的网关。 现在我们要支持websocket,所以我们需要将zuul 1迁移到zuul 2或spring cloud ga
我正在使用 spring boot + netflix zuul 为我的微服务项目开发一个网关。网关连接到 netflix eureka 服务器并过滤请求。但我无法启动 zuul 服务器 我在我的 S
来自 Spring Cloud Greenwich 发布的公告,见 https://spring.io/blog/2019/01/23/spring-cloud-greenwich-release-i
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 6 年前。 Improve this ques
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我正在尝试向 Eureka 服务器注册我的微服务。但它显示浏览器中没有可用的实例。我在控制台中没有收到任何错误。请帮我解决这个问题。 我已经通过谷歌搜索尝试了多种选择。尽管如此,我还是无法解决这个问题
我是一名优秀的程序员,十分优秀!